Need help with io in C++, have read much programmed little?
I am somewhat familiar with input/output in programming, but am having problems using file io in C++. This is my skeleton type program:
#include <stdio.h>
#include <fstream.h>
int main(int argc, char *argv[])
{ ifstream filein; ofstream fileout; char ch;
filein.open("input.txt", ios::in);
fileout.open("output.txt", ios::out);
for(filein.get(ch); ch!=EOF; filein.get(ch));
{
fileout.put(ch);
}
filein.close();
fileout.close();
return 0;
}
i created a text file input.txt and output.txt, input has "asd" in it and output is empty, i want it to write the asd to output.txt
using EOF it is infinite loop, and using NULL it terminates doing nothing, I have read a lot about c/c++ but this is my first stab at programming in it and it is taking me forever to get all syntax and small stuff takin care of. Please tell me what I am doing wrong. Thank you :)
Need help with io in C++, have read much programmed little?learn c++
http://www.cplusplus.com/doc/tutorial/fi...
Please get a better book. The above code is terrible. And outdated.
Just open up two filestreams and transfer one line to another. Use getline to take in entire lines. Store them in strings. As in <string> strings.
EDIT: I'll give you the code. Please get a newer book so you understand what I did.
More Related Questions and Answers ...
The information post by website user , we not guarantee correctness.
Dental Treatment Skin Whitening Skin Problems Skin Rashes Shoes
