Accept a string of multiple words in C using scanf
Today we will see how we can store a string in C.
Suppose if we have try to copy by using scanf:
This will copy only the first word of the string in the array
We have to use scanf with circumflex(^)
Suppose if we have try to copy by using scanf:
char array[24]; scanf("%s",array);
This will copy only the first word of the string in the array
We have to use scanf with circumflex(^)
char array[24]; scanf("%[^\n]",array);The following statement will copy the string passed into the buffer until it received a new line character.
Comments
Post a Comment