Trying to open 2 files one to read in and the other for output

however all the books I have bought are crap they deal with OOP and almost nothing is said about files except that ios::app appends ...etc.
I am trying to read in a file and not trunc it and be able to seek in the file and output the changed values to a created file while leaving the origianl file unaltered.I chose c++ because it is portable, I didn't know that the books I bought wouldn't tell me how to read certain portions of a file and output to another. I have about eight books -all are useless concerning this.
Can someone please reccomend a good book on this or a tutorial? I really don't care about the OOP stuff yet.
Also is 1A the EOF like it is in assembly?
Ok, take a minute and calm down, if you are one to drink coffee\tea I suggest getting a cup right about now.

It's simple, you just need to know the language and how to think like a programmer which a book really can't teach you.

Check out this section: http://www.cplusplus.com/reference/iostream/

From there:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
   string Input_Filename = "Your_input_File_Name.ext";
   string Output_Filename = "Your_output_File_Name.ext";
   ifstream input_File(Input_Filename, ios_base::in); /* This is your input file handle*/
   ofstream output_File(Output_Filename, ios_base::app); /*This is your output file handle*/

/*What do you want to do with the data?*/
Last edited on
Thanks
I want to read in 4 unsigned chars and alter them and output to another file the altered chars and then increment to do the next 4 unsigned chars in the input file to the output file.
I am confused about how to go about doing this. My books don't tell me anything about how to work with input files they are only concerned with writing structs to output files.
Did you take a look at the tutorial on this site?
http://cplusplus.com/doc/tutorial/files/
Thanks I looked for a tutorial but must have overlooked it.
Topic archived. No new replies allowed.