Thread: Best way to input/output string

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    6

    Best way to input/output string

    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.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    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.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    11
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM