Ritu Raj
I am not able to understand it properly on internet
Ritu Raj
BinaryByter
translated for normies: use google
Ritu Raj
Ritu Raj
* means what here?
Ritu Raj
scanf("%[^\n]%*c",s)
BinaryByter
well, look at what happens when you remove the *
Ritu Raj
It will be scanf("%[\n]%c",s)!
The first line%[\n] indicates taking input until enter button is hit....
Then what is %*c? is it a character pointer input???
BinaryByter
try it out
Ritu Raj
Ohk
Ritu Raj
Here it is taking whole string!!
Ritu Raj
Ritu Raj
But here p string is not working
Anonymous
Ritu Raj
Why I am not able to print p string here??
Anonymous
what are you printing
Ritu Raj
But in other compiler I am able to print it using same scanf("%[^\n]s",s);
Anonymous
OH i see what happened
Ritu Raj
Welcome to c!!
Anonymous
you need to fget(stdin)
Anonymous
right before that
Anonymous
the \n is still in the buffer
Anonymous
the other way is to go into your scanf("%s"
Anonymous
and change that to "%s\n"
Anonymous
this will also work
Ritu Raj
Let me try
Ritu Raj
Ritu Raj
But what does this mean??
Anonymous
It works!!
now you must kill your first born kid for me
klimi
Anonymous
it means you still had \n in the buffer
klimi
Don't say such stuff here
Abdulaziz
Hello everyone
Anonymous
No
yes these are the rules if a linux user helps you
klimi
klimi
Abdulaziz
What it is up ?
Anonymous
well then i can never go back to africa
Anonymous
or india
klimi
Your problem
Ritu Raj
Storing \n in buffer will how let this print "welcome to c!!" In next line??
Ritu Raj
I mean?
Anonymous
Anonymous
you do not get it
Anonymous
so when you click enter
Anonymous
\n gets appended to the string
Anonymous
so now you have a string
Anonymous
let's say it is now "hello\n"
Anonymous
now %s reads till the first whitespace
Anonymous
which is \n
Anonymous
so it will read hello into string s
Anonymous
now you try to read a string till the first whitespace
Anonymous
since we did not clear the \n
Anonymous
from the previous time it will do that
Anonymous
so you need to clear the \n manually
Anonymous
technically you should be doing the same in the first case as well
Anonymous
but i do not know the specifics of where you are running your code
Ritu Raj
Thank you Soros now I understand 😇😇😇
Ritu Raj
Thank you for explaination😇
Anonymous
welcome
Abdulaziz
Who’s visual studio 2015?
Ritu Raj
Scanf ("%s\n"); how does it remove \n from buffer??
klimi
Ritu Raj
@GeneralSoros
Anonymous
Anonymous
then it continues scanning and finds a \n
Anonymous
clearing that \n from the buffer
Anonymous
seems pretty straight forward
Ritu Raj
Anonymous
I want lean programming ...I need help ..
Anonymous
I was wrongly warned
Dima
read rules y’all
Anonymous
Yess hmmm
Anonymous
😞😞
Anonymous
Hi
Anonymous
klimi
hi
Sid Sun
hey, i've been having trouble outputting a number to a file using c; the code is here: https://gist.github.com/Sid-Sun/103c42efaa86ec8be274cd42ab76eaac as you would see, i give it a=1 but it just writes ^A to the file.