What is the difference between GETS();AND SCANF();

Answer Posted / vignesh1988i

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a union?

595


How do I create a directory? How do I remove a directory (and its contents)?

596


how to create duplicate link list using C???

2053


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

1892


how do you programme Carrier Sense Multiple Access

1501






Subtract Two Number Without Using Subtraction Operator

343


Is r written in c?

714


Write a program to check whether a number is prime or not using c?

563


Is c still used?

586


Can include files be nested?

616


Describe how arrays can be passed to a user defined function

765


What is function prototype in c with example?

561


Why is c called a structured programming language?

662


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

613


define string ?

656