Thread: how to remove this broken line in the end?

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    18

    how to remove this broken line in the end?

    I have this source and im trying to use it on linux:

    Code:
    #include <iostream>
    #include <sstream>
    #include <fstream>
    using namespace std;
    int main ()
    {
    	char c;
    	ifstream in_file("./texto");
    	ostringstream var1;
    	while (in_file.get(c))
    	{
    		var1 << c;
    	}
    	cout << var1.str() << endl;
    	return 0;
    }
    the content of "texto" is:
    Code:
    teste1
    teste2
    to compile with g++-4.3:

    Code:
    $ g++ teste2.cc -o teste
    then i have this:

    Code:
    fbs777@Linux1:/tmp$ ./teste
    teste1
    teste2
    
    fbs777@Linux1:/tmp$
    using the linux to read the file texto dont show anything after line2:

    Code:
    fbs777@Linux1:/tmp$ cat ./texto
    teste1
    teste2
    fbs777@Linux1:/tmp$

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    so maybe you should remove the endl from your output?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    18
    thank you, that was because the "<< endl"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  3. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  4. command line alias remove for linux
    By iain in forum Tech Board
    Replies: 6
    Last Post: 11-22-2004, 01:39 PM
  5. read to end of line problem
    By one1082 in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2003, 04:30 PM