C
C++ Newbie
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:ut);
while (i < 100)
{myfile << i << "\n";
i++;
}
system ("echo Third last line of file is:");
system ("tail -3 temp.txt | head -1");
}
Thanks.
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:ut);
while (i < 100)
{myfile << i << "\n";
i++;
}
system ("echo Third last line of file is:");
system ("tail -3 temp.txt | head -1");
}
Thanks.