Accept a string with newline

This is a discussion on Accept a string with newline within the C Programming forums, part of the General Programming Boards category; Hi, I would like to know what function should I use if I want the user to input a string ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    11

    Accept a string with newline

    Hi, I would like to know what function should I use if I want the user to input a string with the new-line character. fgets terminates reading after a new-line character is found.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,758
    It depends. For example, you could use fgetc and read until some other character that signals the end of the input, or until a certain number of characters has been read. It may still be feasible to use fgets, depending on how exactly you want to read the input.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well... you could add it manually.... Take a look at the strcat() function in your docs.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please check my C++
    By csonx_p in forum C++ Programming
    Replies: 263
    Last Post: 07-24-2008, 09:20 AM
  2. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 06:52 PM
  3. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 01:45 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21