Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Linux/C++ syste...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 45042 of 48022
Post > Topic >>

Linux/C++ system call problem

by "C++ Newbie" <newbie.cpp@[EMAIL PROTECTED] > Apr 18, 2008 at 06:51 AM

Hi,

Why doesn't the following C++ program echo the value of 97? If you
manually "head -3 temp.txt | tail -1" the temp.txt file, you will get
97. Use it in a system call, and it doesn't work.

#include <fstream>

using std::fstream;
using std::ios;

int main()
{
int i = 0;
fstream myfile;
myfile.open ("temp.txt", ios::out);
while (i < 100)
	{myfile << i << "\n";
	i++;
	}
system ("echo Third last line of file is:");
system ("tail -3 temp.txt | head -1");
}


Thanks.
 




 10 Posts in Topic:
Linux/C++ system call problem
"C++ Newbie" &l  2008-04-18 06:51:29 
Re: Linux/C++ system call problem
"Victor Bazarov"  2008-04-18 10:00:11 
Re: Linux/C++ system call problem
"Victor Bazarov"  2008-04-18 10:00:39 
Re: Linux/C++ system call problem
Sherman Pendley <spamt  2008-04-18 11:14:13 
Re: Linux/C++ system call problem
Pete Becker <pete@[EMA  2008-04-18 13:07:56 
Re: Linux/C++ system call problem
"Andrew Koenig"  2008-04-18 15:24:36 
Re: Linux/C++ system call problem
pjb@[EMAIL PROTECTED] (P  2008-04-18 16:05:37 
Re: Linux/C++ system call problem
"Alf P. Steinbach&qu  2008-04-18 16:07:28 
Re: Linux/C++ system call problem
James Kanze <james.kan  2008-04-18 13:20:21 
Re: Linux/C++ system call problem
"Alf P. Steinbach&qu  2008-04-19 08:16:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:38:50 CDT 2008.