read line from stdin

5 posts / 0 new
Last post
JosDuchIt
JosDuchIt's picture
Offline
Last seen: 7 years 4 months ago
Joined: 2012-01-08 20:57
read line from stdin

How do you read a line from stdin ?

i lost my time with gets which seems not te be available.
Tried to use FGets, but get errors.

thomas
thomas's picture
Offline
Last seen: 1 day 3 hours ago
Joined: 2011-05-16 14:23
FGets

FGets (Input(),buffer,buffer_size);

JosDuchIt
JosDuchIt's picture
Offline
Last seen: 7 years 4 months ago
Joined: 2012-01-08 20:57
Thanks Thomas. I searched

Thanks Thomas.
I searched more than an hour for this info.

Any idea why this program does not give me the opportunity to enter a string?

8.Amiga OS 4:S> guis:c/test
Please enter a string
str

8.Amiga OS 4:S>

  1. int main(void) {
  2. char str[100];
  3.  
  4. Printf("Please enter a string\n ");
  5. FGets(Input(), str, 80);
  6. Printf("str %s\n",str);
  7. ///printf( makeupper(str));
  8. return 0;
  9. }
Rigo
Rigo's picture
Offline
Last seen: 1 year 10 months ago
Joined: 2011-01-24 21:55
Have you tried scanf()

Have you tried scanf() ?

Simon

thomas
thomas's picture
Offline
Last seen: 1 day 3 hours ago
Joined: 2011-05-16 14:23
Any idea why this program

Any idea why this program does not give me the opportunity to enter a string?

I don't have the possibility to try it out soon. But I guess it has something to do with buffered I/O which might not be supported by the CON window. Try this instead:

Read (Input(), str, 80);

Note that this only works for a window. If you read from a file it will not stop at \n.

Log in or register to post comments