struntz
Nov 12th, 2000, 08:00 PM
Hello i'm pratically a newbie to C++ i have only been programming in VB, but my problem is this: i am reading a book called "Thinking in C++" and they tell me this:
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int main() {
ifstream in("CoryS.cpp"); //opening file for reading
ofstream out("CoryS2.cpp"); //opening file for writing
string s;
while(getline(in, s)) //discards newline char
out << s << "/n"; // ... must add it back
}
And it is suppose to copy the contents of one file into the other, and it does nothing i made the first file CoryS.cpp say "hello this is just a test" and the CoryS2.cpp a blank file with nothing in it....and it didn't work, anyoen know why/>
if so please post! :D
Thanks for listening!
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int main() {
ifstream in("CoryS.cpp"); //opening file for reading
ofstream out("CoryS2.cpp"); //opening file for writing
string s;
while(getline(in, s)) //discards newline char
out << s << "/n"; // ... must add it back
}
And it is suppose to copy the contents of one file into the other, and it does nothing i made the first file CoryS.cpp say "hello this is just a test" and the CoryS2.cpp a blank file with nothing in it....and it didn't work, anyoen know why/>
if so please post! :D
Thanks for listening!