answersLogoWhite

0

Because it is not a character, it is a pointer. Anyway, the following is perfectly legal:

char str [4] = { 'A', 'B', 'C', (char)NULL};

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

How can i check a null at the end of an character array in java?

A character array, by nature, is a primitive-type data array. It can't contain a null value. You cannot cast a char as a null. char[] charArray = {'1','2','s',null}; //this doesn't compile. However, if you have an array of Character objects, then it's possible. Character[] charArray = {'1','2','s',null}; //this DOES compile A proposed algorithm is to initialize a test boolean as false, then use a for loop to iterate through the array. Set the flag to true (and break the loop) based upon whether one of the objects you run into is null. What you do from there is up to what the rest of your code says.


How strings and characters are represented in an array?

An array of characters is an array of character codes (such as ASCII codes). A string is typically a null-terminated array of characters however some languages use the first array element to specify the string's length.


What is null character and what is its use in context of string?

null character exists at the end of the string.It denotes the end of it.


How you work character type data in array c plus plus?

It's not clear from the question what you mean by "work". However character data types (char and wchar_t) are intended to store character codes and they work exactly the same whether as a single variable or as an array of characters. If you want to use the array as a string, however, remember to include a null-terminator at the end of the string.


Why strcat(string'!') not work in C program?

The strcat() function has the following protocol:char* strcat (char* destination, char* source);The function appends the source string to the destination string and returns the destination string.The destination string must be a null-terminated character array of sufficient length to accommodate strlen (source) plus strlen (destination) characters, plus a null-terminator. The existing null-terminator and subsequent characters of destination are overwritten by characters from the source string, up to and including the source string's null-terminator.strcat (string, '!') will not work because '!' is a character literal (ASCII code 33 decimal), not a null-terminated character array. Use "!" instead of '!'.Example:char string[80]; // character arraystrcpy (string, "Hello world");strcat (string, "!");puts (string);


When an array name is passed to a function the function?

All array names will implicitly convert to a pointer to the first element in the array. Note that when passing an array to a function, you must also pass the array length as a separate argument because the pointer alone cannot tell you how many elements were actually allocated to the array, let alone how many are currently in use. However, there are some exceptions. For example, a null-terminated string argument does not require a length argument as the null-terminator denotes the end of the character array. User-defined arrays can use a similar technique, using any "unused" or "invalid" value or token to denote the end of the array. Note that the following function signatures are identical: void f (int* a, unsigned len); void f (int a[], unsigned len); The latter is more readable as it makes it clear the pointer refers to an array. When passing multi-dimensional arrays, you must add an extra level of indirection for each additional dimension: void g (int* a[], unsigned rows, unsigned cols); // two-dimensional array void h (int** a[], unsigned width, unsigned height, unsigned depth); // three-dimensional array Multi-dimensional arrays can also be null-terminated or terminated by a designated token value. The canonical example of this is a global main function which accepts command line arguments. These arguments are passed through a null-terminated array of null-terminated strings (a two-dimensional array of type char). int main (char* argv[], int argc) { assert (argc>=1); // always at least one element assert (argv[0] != NULL); // the first element is always the executable name (non-NULL) assert (argv[argc-1] != NULL); // the last element is always non-NULL assert (argv[argc] == NULL); // the one-past-the-end element is always NULL return 0; }


Use of gets in c?

Gets reads the next input line into an array ; it replaces the terminating newline with '\0'. it returns the array or null if end of file or error occurs.


What is a character array?

A character array is list of pointers that point to characters. The way to use an array would depend on the language. Most arrays are 0 indexed meaning they begin at 0.


How do you use character in c plus plus?

If you are referring to the character object 'char,' then here are a couple of uses:To create an object, use this:char object = 'a';To create an array of chars, use this:char array[10];To dynamically allocate an array of chars, use this:char array = new char[10];(Don't forget to delete the object with 'delete [] array')


Why numeric arrays do not end with a '0' in C programming language?

The value zero is a perfectly valid numeric array element in its own right. If we used the value zero to mark the end of a numeric array in the same way we use a null-terminator to mark the end of a string (a character array), we'd have no way of representing the value zero within the array itself. Thus when working with numeric arrays, we must keep track of the array length independently of the array.


How are string variables stored?

Typically as null-terminated character arrays. However, some languages use the first element of the array to store the length of the string rather than a null-terminator to mark the end of the string.


How many character can store a character variable at a time?

One. If you want more, use an array.