I have been reading C book by K&R. I came across this words
Character arrays are a special case of initialization; a string may be used instead of the braces and commas notation:
char pattern = "ould";
is a shorthand for the longer but equivalent
char pattern[] = { 'o', 'u', 'l', 'd', '\0' };
In this case, the array size is five (four characters plus the terminating '\0').
I coded a simple program to test it as
#include<stdio.h>
int main()
{
char c= "Hello";
printf("%s",c);
return 0;
}
According to that book there should be no error but it returns an error
`cannot convert char * to char`
As per my previous knowledge of arrays,the array statement should be like char *c="Hello";
Can you explain the meaning of the words in that book please. Did i Misunderstand the meaning of that words??
char pattern[] = "ould";. If you have a digital copy (you did say you copied and pasted it), it may have been an oversight in the transcription or automated scanning process.