Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



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

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

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

Answer / 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

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

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

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

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

Post New Answer

More C Interview Questions

Explain what are multibyte characters?

0 Answers  


what is const volatile?

2 Answers  


If "AaBbCc" is passed to the char char x(*a) { a[0]?x(a+1):1; printf("%c",a[0]); return 1; } what will be the output?

6 Answers   Hughes,


Why is conio.h not required when we save a file as .c and use clrscr() or getch() ?

2 Answers  


What is the use of a ‘’ character?

0 Answers  


Whats s or c mean?

0 Answers  


What is bubble sort in c?

0 Answers  


how many keywords are available in 'c' language a) 32 b) 34 c) 45 d) 48

1 Answers  


Why does the call char scanf work?

0 Answers  


#include<conio.h> #include<stdio.h> void main() { int i; if(1,0,2,3) { printf("if"); } else { printf("else"); } getch(); } Can any body tell the answer of this question with explanation?

3 Answers   Huawei,


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

0 Answers  


Function calling procedures? and their differences? Why should one go for Call by Reference?

0 Answers   ADP,


Categories