What in your opinion is the best way to input/output string to or from both keyboard & output to monitor OR file.
What in your opinion is the best way to input/output string to or from both keyboard & output to monitor OR file.
Last edited by ruab; 08-31-2006 at 07:23 AM.
It's somewhat difficult to read a string from the mouse, but for all other string input, fgets tends to be a favorite. For output, fputs works nicely.
My best code is written with the delete key.
what it's important is to know that you cannot trust in any determined size , that's why fgets is a nice function because you call it saying you want to read at most N chars, so in this way you avoid to overflow the buffer.
(Typical security problem)
Well, my favourites are always the standard ones, fread, fwrite, fgets, etc. In that way you assure portability.
About to print to the screen, well, I guess that is the point where perhaps there are more differences... I remember the clrscr() or something similar of the old Turbo C.... totallly non-standard ;-)
I guess for screen you really ask for something more than the printf. and, in that point, you have to use a library (NCURSES for instance in unix...)
--------------
http://www.uberum.com