AW: [En-Nut-Discussion] --fgets function question--
Ernst Stippl
ernst at stippl.org
Sun Jul 30 08:35:27 CEST 2006
Hi Raul!
fgets waits for a string (upto the newline char) to arrive.
Have a look at the sample programs: uart.c tcps.c
in uart.c you will find the following code sequence:
/*
* A bit more advanced input routine is able to read a string
* up to and including the first newline character or until a
* specified maximum number of characters, whichever comes first.
*/
fputs("\nEnter your name: ", uart);
fflush(uart);
fgets(inbuf, sizeof(inbuf), uart);
/*
* Chop off trailing linefeed.
*/
cp = strchr(inbuf, '\n');
if (cp)
*cp = 0;
/*
* Streams support formatted output as well as printing strings
* from program space.
*/
if (inbuf[0])
fprintf(uart, "\nHello %s!\n", inbuf);
else {
fputs_P(pgm_ptr, uart);
hope this hels
regards
ernst
-----Ursprüngliche Nachricht-----
Von: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] Im Auftrag von Raul Valle
Gesendet: Sonntag, 30. Juli 2006 04:34
An: en-nut-discussion at egnite.de
Betreff: [En-Nut-Discussion] --fgets function question--
Hi to all :
question: does the fgets function when called , does it waits until it
receives data (just like a regular c++ program , that waits for the input)
or if at the exact scan time that the function is called , if theres nothing
it continues the program sequence????
Thanks in advance
_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.5/403 - Release Date: 28.07.2006
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.5/403 - Release Date: 28.07.2006
More information about the En-Nut-Discussion
mailing list