What is the difference between GETS();AND SCANF();
Answers were Sorted based on User's Feedback
Answer / bharath
gets() read the string values which allows white spaces
also. whereas, scanf() doesn't allow.
| Is This Answer Correct ? | 230 Yes | 19 No |
the main difference between gets() and scanf() function is that while getting any input as a stream of characters or as a string using scanf() , the end termination character is a blank space or an enter key for scanf() , so upto blank space it will be saving it in the memory...... SHORTLY it ignores the characters comin after and with blank spaces........
in gets() , it allows with the blank spaces and the termination condition is a enter key (\n) ,
but a inside gets() function , surely they would have used scanf() function , but the difference is that the input inside gets() would go character by character , so only gets() can allow with the blank spaces...........
thank u
| Is This Answer Correct ? | 103 Yes | 47 No |
Answer / niraj kumar
Main difference between '%s' and 'gets' is:
%s ends taking input when it encounter whitespace, new line(
) or EOF.
gets takes whitespace and stops taking input when it encounters new line(
) or EOF.
| Is This Answer Correct ? | 14 Yes | 9 No |
Answer / rejith vr
We can use scanf() instead of gets()
Syntax : gets(str);
||
||
scanf("%[^
]s",str);
it will accept multiple words in a string
| Is This Answer Correct ? | 5 Yes | 23 No |
logic for x=y^n
why do we use pointer instead directly acessing the data?
What's the difference between constant char *p and char * constant p?
How will you find a duplicate number in a array without negating the nos ?
Differentiate call by value and call by reference?
What are shell structures used for?
What are the languages are portable and platform independent?Why they are like that?
what is the c source code for the below output? 10 10 10 10 10 10 10 10 10 10 9 9 7 6 6 6 6 6 6 9 7 5 9 7 3 2 2 5 9 7 3 1 5 9 7 3 5 9 7 4 4 4 4 5 9 7 8 8 8 8 8 8 8 8 9
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
What is meant by inheritance?
Go through the following code sinippet char a[20]; a="Hello Orcale Test"; will this compile?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode