+ 3
in your code,after a single charecter input ,everything is read by gets() up to new line . So after a char input, put string in continuation. not in next line.
hope it helps.
+ 2
i entered "hola" as input and got:
h
ola
as output. Other than using gets(), what's wrong?
+ 2
Verstappen,
I don't know if it's true, I think scanf() has its own issues (cmiiw). This far I've seen people ran into problem when their program needs to read numbers & string in sequence (though not always).
This time I found that reading char also has tricky parts : )
+ 1
Ahhh yeah yougotta treat the input as a stream, and as Jay explained
+ 1
Verstappen,
I mean add
getchar(); // return value not assigned to anything
Just a line before you read the string, using either gets() or fgets().
* It is highly recommended to NOT use gets()
+ 1
Replace gets(b) with fgets(b, 100, stdin);
+ 1
The gets() function is used to read input as an ordered sequence of characters, also called a string.
A string is stored in a char array.
0
Verstappen,
It could be, in that case, try to call getchar() without assigning the return value, just before reading the string.
I tried to change gets() with fgets() and the string was still read as blank, until getchar() was placed in, prior to reading the string.
It is however a good idea to NOT use gets() cause it's been known for being insecure.
0
Hello Ehouman Jhon Elohim,
Please, for your own safety and comfort, avoid exposure of personal information such as phone number in public areas such as this forum.
It would be great if you could also remove your phone number in the comments you wrote in people's code, for the same reason.
Regards,
- 2
I am Elohim Ehouman, I am of Ivorian nationality I am a beginner developer who needs your help to improve myself even more, friends I really need help and I would be grateful to you then the one where whoever wants to m 'Help me leave his WhatsApp number or telegram here is mine +2250779604730 thank you in advance