answersLogoWhite

0


Best Answer

Use '%s', eg:

char name[64];

scanf ("%s", name);

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Scanf function in c for strings?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is there a function similar to the C plus plus scanf function in JavaScript?

Scanf is part of the C standard library. Although the C++ standard library includes 18 headers from the ISO C90 standard, their usage in C++ is deprecated. However, to answer the question, there is no equivalent to scanf in JavaScript.


What is the use of scanf function in c?

Hiii,scanf() is an predefined function of C to getting runtime input from the user.Syntax:-scanf("sequence specifier",&variable_name);example:-#includevoid main(){int number;printf("\n Enter any number"); //message to userscanf("%d",&number); //getting input from userprintf("\n entered number is %d",number); // displaygetch();}


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


How do you give input at run time in c?

Usually by using the scanf function


Which function is used to read data from the console?

The scanf() function in the <stdio.h> C standard library header.


What is standard library function in c?

The Standard Librarary Function in C is printf,scanf inf Standard input output header.. which is stdio.h.


What are the limitations of getchar and scanf functions for strings?

cause getchar only read a character and scanf read only word before first space but not other words and letters.


What happens by the scanf statement in c?

It's a function, not a statement. Use your help system to find out its purpose.


How do you read a character from the keyboard and will store it in the variable?

Use the scanf() function from the C standard library.


Can you use scanf function within printf function?

Yes: double d; printf ("scanf's just returned %d\n", scanf ("%lf", &d));


Why not use the ampression symbol in scanf statement in function?

scanf is a function, not a statement. Example: int a; char name[12]; scanf ("%d %s", &a, &name[0]);


In c language strings why gets function allows blank spaces but scanf function does not?

The 'gets' routine is designed to return all characters up to the end of the line, including embedded spaces.The 'scanf' routine returns values based on a format; if you are using the %s format conversion, it will stop when it encounters a white-space character (such as the space).The two routines are used for different things. With 'gets' it is assumed that you will parse and convert anything in the line yourself, whereas the scanf routine helps to parse items out in the format that you want (most of the time).see: In_c_language_strings_why_gets_function_allows_blank_spaces_but_scanf_function_does_not