Ignore the spaces when loading

This is a discussion on Ignore the spaces when loading within the C++ Programming forums, part of the General Programming Boards category; Hi guys, i just wonder that there is any code that ignore the space when loading a file using fstream, ...

  1. #1
    Computer guy
    Join Date
    Sep 2005
    Location
    I'm lost!!!
    Posts
    200

    Ignore the spaces when loading

    Hi guys, i just wonder that there is any code that ignore the space when loading a file using fstream, except when it enter new line.

    ex:
    this is what the text file contain:

    Code:
    The file need to load
    1
    2
    3
    4
    usally, when use like this:
    Code:
    char a[100];
    Load >> a;
    it will stop at "The" and will load the word "file" to the next character variable.

    Please help me. Thanks
    Hello, testing testing. Everthing is running perfectly...for now

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    use getline() if you want the entire line, including all spaces. There are two version of getline() -- fstream.getline(...) is for c character arrays, and getline(fstream,std::string) is for std::string (recommended in c++ programs unless there is a verrrrry good reason to use c character arrays)

  3. #3
    Computer guy
    Join Date
    Sep 2005
    Location
    I'm lost!!!
    Posts
    200
    I did it, thanks alot AD
    Hello, testing testing. Everthing is running perfectly...for now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cargo loading system
    By kyle rull in forum C Programming
    Replies: 1
    Last Post: 04-20-2009, 12:16 PM
  2. Changing 3 spaces to tabs
    By dnguyen1022 in forum C Programming
    Replies: 2
    Last Post: 12-21-2008, 11:51 PM
  3. ignore spaces & eof
    By Cpro in forum C++ Programming
    Replies: 6
    Last Post: 03-23-2008, 04:58 AM
  4. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  5. Loading Screen
    By pinkcheese in forum Windows Programming
    Replies: 2
    Last Post: 04-06-2002, 10:48 PM

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