answersLogoWhite

0

Difference between cin and scanf

Updated: 8/10/2023
User Avatar

Wiki User

11y ago

Best Answer

the getchar function waits the user hit a key followed by return key. Upon the return key hitted by the user the function returns the key. But the scanf can be used for various & different user entered data including text, integer, float and so on. in spite of getchar the delimeter keys for scanf function are tab, space and return key; so when a space entered by the user in the input the scanf will end the input and waits user enter the return key. You must take in mind that just the fragment of input that is behind these delimeters will be considered as legal input for the scanf and the remaninder will be escaped.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

The result: 'gets' just reads a line, 'scanf' parses the input and reads data into one or more variables, according to the format string.

by nazir husain

D-5 kalaka ji New Delhi -19

contect no 9717416642

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

The main difference between these gets and scanf function is that gets allows to read white spaces but scanf doesn't allow.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

The result: 'gets' just reads a line, 'scanf' parses the input and reads data into one or more variables, according to the format string.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

cin is an object of type istream, scanf is a function. They are no way similar.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between cin and scanf
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is difference between scanf and cin?

scanf is a function (available in C and C++)cin is an istream object (C++ only)Advice: when in doubt, use fgets+sscanf


What is the difference between the printf and scanf statements in C?

well major difference between scanf and printf is that scanf is an input statment and printf is an output stament scanf is used to take data in from the user and printf is used to display the result on the screen Regards


What is Cin and Cout?

The cin and cout objects are iostream objects somewhat equivalent to stdin and stdout. The equivalent of printf ("Hello World\n"); is cout << "Hello World" << endl; The equivalent of scanf ("%d", &i); is cin >> i;


How do you use scanf with delimiter in c plus plus Please provide a basic example with output?

scanf does not employ a delimiter. It simply reads formatted input from std::cin.


What is the different between cin and scan f?

about proggraming


What are the advantages of cout and cin intsead of printf and scanf?

printf and scanf apply to C strings and are not considered type safe for C++ programming. The format specifiers are also quite cryptic. Although they often result in shorter code, it is arguable whether the code is more readable. The C++ standard library is type safe and makes it abundantly clear what is going on.


How you get the size of arrays from user?

in c simply add three lines in the begining of your program: int x; printf("enter the size of the array to be entered :"); scanf("%d",&x); after that use x as your maximum limit of array in your program. in c++ just replace above printf & scanf statements by cout<<"enter the size of the array to be entered :"; & cin>>x; respectively and do not use brackets.


What are the ratings and certificates for Cin cin - 1992?

Cin cin - 1992 is rated/received certificates of: Iceland:L Italy:T Sweden:Btl UK:15 USA:PG-13


La difference entre gets getchar scanf?

Excusez mon français pauvre mai the difference between getting the computer code for a particular letter of character and something else is easier to answer if I know what the other way is, veuillez terminer la question


When was Kadir Cin born?

Kadir Cin was born in 1987.


What is CIN?

cin is the object of istream class i.e, input class.


When was CiN Weekly created?

CiN Weekly was created in 2003-10.