Array (getline)

This is a discussion on Array (getline) within the C++ Programming forums, part of the General Programming Boards category; Hi, I have a question and need some help with getline. I am opening a file and getting the whole ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    12

    Question Array (getline)

    Hi,
    I have a question and need some help with getline. I am opening a file and getting the whole line and putting it in a buffer. Now ofcourse the line contains blank or white spaces and I want to delete all this white spaces only, leaving me with no white space characters only.
    for example:
    lets say my buffer reads:
    p = 1 2 3 4 2 3

    I want to delete the white spaces so it will read:

    p=123423

    I am not sure how to do that. can any one help me out please. Thank you in advance.
    p.s.

    Here is how I am getting each line.

    Code:
    while(inFile.peek() != EOF)
    {
    for(int b =0; b<buffersize; b++)
    { buffer[b] = '\0'; }
    
    inFile.getline(buffer, buffersize);
    
    for(int o=0; o<buffersize; o++)
    {cout<<buffer[o];}
    cout<<endl;
    }
    Last edited by softcoder76; 03-06-2002 at 09:49 PM.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    12

    Talking

    Any one willing to help....

  3. #3
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Code:
    for(int o=0; o<buffersize; o++)
       if(buffer[o] != ' ')
            cout<<buffer[o];
    cout<<endl;
    }
    Don't bump your threads.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 11:33 AM
  2. Replies: 7
    Last Post: 11-25-2008, 01:50 AM
  3. 1-D array
    By jack999 in forum C++ Programming
    Replies: 24
    Last Post: 05-12-2006, 08:01 PM
  4. getline to store values in an array
    By berenice in forum C++ Programming
    Replies: 6
    Last Post: 07-10-2002, 11:17 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 09:31 AM

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