Can i knw why is an error appearing here..even though output is received | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can i knw why is an error appearing here..even though output is received

https://code.sololearn.com/cSpi3g911r3Q/?ref=app

31st Dec 2019, 10:00 AM
Y AD Ù
Y AD Ù - avatar
5 Answers
+ 4
it should be scanf("%s", x);
31st Dec 2019, 10:04 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
In scanf we specify address as a second parameter. For if x[], is an array, the variable x points to first Location. First parameter %s, means take word so read chars until space encounters.. For more clarification see this,.. https://code.sololearn.com/cLRi914Y81vC/?ref=app
31st Dec 2019, 7:42 PM
Jayakrishna 🇮🇳
+ 1
&x means address of x. Input stored at the address of specified location by &x. Primitive values required to store at corresponding variable addresses so we specify &x but in your program x is char array. In c, if omit [], it points address of 0th location. So while dealing with char Arrays you don't need to put &, it is already pointing to first element of array address... Array means continuous memory locations os same type.
31st Dec 2019, 5:53 PM
Jayakrishna 🇮🇳
0
✳AsterisK✳ so..here '&' isnt used...why?
31st Dec 2019, 11:05 AM
Y AD Ù
Y AD Ù - avatar
0
Jayakrishna so just by pointing to the first element of array address..the whole collection of characters can be stored?
31st Dec 2019, 6:06 PM
Y AD Ù
Y AD Ù - avatar