Need help with io in C++, have read much programmed little?

 Dont Buy Textbooks. Rent 'EM Save 60-80%



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.


FirstPrevious12NextEnd

More Related Questions and Answers ...
  • C++: How do you edit a char string from a dif..
  • C++ Error message?
  • C++ programing this is part of my study guide..
  • C++..program runs fine but with errors in the..
  • C++ array to hold full name (first last) as a..
  • HELP!!! C++ PROBLEM! Someone Please HELP!?
  • Need help with a c++ Code?
  • How do i write a c++ program that reads the t..
  • C++ Help- Input and Output txt document?
  • C++ reading from file into array using a func..
  • C++ run-time failure. please help?
  • C++ Help, Please: Syntax for passing/receivin..
  • C++ problem involving searching a text file f..
  • How to recognise whitespaces in c++ by using ..
  • [C++] Why the result of my programme is "..
  • C++, using default file name?
  • C++: fstream user input ?????? NEED HELP!?
  • Need help excuting a outfile, infile problem ..
  • Help with C++ code?

  • The information post by website user , we not guarantee correctness.

    

    Dental Treatment Skin Whitening Skin Problems Skin Rashes Shoes