how to remove this broken line in the end?

This is a discussion on how to remove this broken line in the end? within the C++ Programming forums, part of the General Programming Boards category; I have this source and im trying to use it on linux: Code: #include <iostream> #include <sstream> #include <fstream> using ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,468
    so maybe you should remove the endl from your output?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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, 08: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, 12:39 PM
  5. read to end of line problem
    By one1082 in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2003, 03:30 PM

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