why we wont use '&' sing in aceesing the string using scanf



why we wont use '&' sing in aceesing the string using scanf..

Answer / Archana Kumari

Using '&' (apostrophe and ampersand) within a string when reading input using scanf can lead to unexpected results because these symbols have special meanings in C programming. To read a string with spaces or special characters, use the format specifier %s instead of %c. For example:
char str[100];
scanf("%s", str); // reads an entire line into str

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Is calloc better than malloc?

1 Answers  


Which of the Following will define a type NODE that is a node in a Linked list? A)struct node {NODE*next;int x;};type def struct node NODE; B)typedef struct NODE {struct NODE *next;int x;}; C)typedef struct NODE {NODE *next;int x;}; D)typedef struct {NODE *next;int x;}NODE;

5 Answers   Accenture, TCS,


WHAT IS MEANT BY LIFE?

2 Answers  


What happens if a header file is included twice?

1 Answers  


Where static variables are stored in c?

1 Answers  


Which is better pointer or array?

1 Answers  


i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....

1 Answers   RBI,


44.what is the difference between strcpy() and memcpy() function? 45.what is output of the following statetment? 46.Printf(“%x”, -1<<4); ? 47.will the program compile? int i; scanf(“%d”,i); printf(“%d”,i); 48.write a string copy function routine? 49.swap two integer variables without using a third temporary variable? 50.how do you redirect stdout value from a program to a file? 51.write a program that finds the factorial of a number using recursion?

6 Answers   Amdocs,


How can I open a file so that other programs can update it at the same time?

1 Answers  


Why can’t we compare structures?

1 Answers  


How can you print HELLO WORLD without using "semicolon"?

7 Answers   HCL, Infosys,


how to capitalise first letter of each word in a given string?

1 Answers  


Categories