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:
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

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

PR, PN and PV Variable in Yocto