saving . . . saved Regarding syntax of 'scanf' function. has been deleted. Regarding syntax of 'scanf' function. has been hidden .
Regarding syntax of 'scanf' function.
Title
Question
In the program, we write, scanf("%[^\n]s", string_name).

I tried missing the [^\n] part, but the result is virtually the same. 
Please explain, what exactly is its use in spacing?

C-and-Cpp Strings 02-03 min 0-10 sec 23-10-20, 12:24 p.m. bsscharan

Answers:

In C programming language, whenever scanf() function encounters space, it stops taking further more input for a particular variable.  ^ is the caret operator and it helps us to ignore a particular character. Thus, when we write "^\n" in scanf() function, we will be able to write strings with spaces (like hello world) and also be able to store in a particular variable, until \n (here, \n is Enter key) is encountered. For more, click https://www.quora.com/What-is-scanf-n
25-10-20, 12:04 a.m. sudhakarst
Thank you sir
25-10-20, 12:43 p.m. bsscharan

Login to add comment


Log-in to answer to this question.