I am going through one small code where I need to take whole line as input through scanf function, and I think there is one format specifier "[^\n%*c]" can someone please tell me syntax for it and how it works?
The format specifier you show isn't complete, or even correct. Better use fgets if you want to read whole lines, it's much simpler (and assuming correct arguments won't lead to buffer overflows).
int result = scanf(" %99[^\n]", string); where 99 is the string size -1, and it leaves the newline in the input buffer. The leading space before % is to consume previous whitespace. The result is the number of successful conversions. It is generally poor practice to try to eat subsequent whitespace.
fgetsif you want to read whole lines, it's much simpler (and assuming correct arguments won't lead to buffer overflows).int result = scanf(" %99[^\n]", string);where 99 is the string size -1, and it leaves the newline in the input buffer. The leading space before%is to consume previous whitespace. Theresultis the number of successful conversions. It is generally poor practice to try to eat subsequent whitespace.scanf()is not the proper tool for the job. It can do it, just like an hammer can be used to drive a screw in :-)