There are two widely used formats to represent a block of data: a pointer and an array:
char * cPtr;
char buf[80];
The name of an array is a constant pointer to the first element of the array. Therefore, the name of a charcter array is equal to const char *. You can not assign anther address to the array name like
buf = cPtr;
The other difference between a pointer and array is: a pointer such as char * cPtr can point to anywhere, most probably somewhere in the OS's territory that you can't access. An array such as char buf[80] however, points to a block of memory allocated by the compiler.
If a block of characters ends with NULL i.e. 0, it can be treated as a string, which is recognized in most applications.
Posted By :-Cplusplusprogramming
char * cPtr;
char buf[80];
The name of an array is a constant pointer to the first element of the array. Therefore, the name of a charcter array is equal to const char *. You can not assign anther address to the array name like
buf = cPtr;
The other difference between a pointer and array is: a pointer such as char * cPtr can point to anywhere, most probably somewhere in the OS's territory that you can't access. An array such as char buf[80] however, points to a block of memory allocated by the compiler.
If a block of characters ends with NULL i.e. 0, it can be treated as a string, which is recognized in most applications.
Posted By :-Cplusplusprogramming