Input full line from file

This is a discussion on Input full line from file within the C++ Programming forums, part of the General Programming Boards category; using Code: infile >> char_array; it only stores in the array the characters in the file untill a space is ...

  1. #1
    Unregis3
    Guest

    Input full line from file

    using
    Code:
    infile >> char_array;
    it only stores in the array the characters in the file untill a space is found. How do I store the entire line in the array?

    Thanks
    -Peter

  2. #2
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    um

    infile.getline(szBuffer, int howlong, delimiter) so..

    Code:
    intfile.getline(szBuffer, 100, '\n');
    //gets 100 characters..or until the enter key in file has been press..and stores in szBuffer..szBuffer can be a pointer to char..but remember to allocate memory or..make it an array of characters..
    nextus, the samurai warrior

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Very strange error...
    By Blackroot in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2006, 12:37 AM
  3. Skipping to a new line in an input file.
    By earth_angel in forum C Programming
    Replies: 15
    Last Post: 06-14-2005, 01:25 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM

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