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

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto