+ 1
When I enter the first input, the program breaks and prints 0
11 Antworten
+ 3
~ swim ~ Didn't knew we can read spaces like that from scanf. I always used gets or fgets for that.
Thanks for telling me about it.
+ 2
Geek
you are doing first scanf wrongly...it should be as below and you are done :
scanf("%[^\n] ",a);
scanf require memory address to store input value and a is already array which don't need to be passed as &a as it means double pointer instead of single pointer... for char x, you can pass &x..for int g, you can pass &g and so on but for array , you should pass directly array...
next point was to have format as %[^\n]s... it means you expect two input... one for %[^/n] and other for s... %[^/n] itself take care of input string with space
+ 1
~ swim ~
Why &a is wrong in first scanf??
We can take input as a string using scanf
+ 1
Ohhk I got it..But one thing i want to ask what happens in memory if we use &a..I mean a has address of first element and if we use &a it will be address of(address of first element)..
+ 1
~ swim ~ Got it!! Thanks
+ 1
Thanks for your help. Because of you only, I am learning new things. Will require more help like this to learn more. Thankyou again!