Does this method work only for Windows or will it work for Linux too?
Type: Posts; User: mosdef
Does this method work only for Windows or will it work for Linux too?
Also, are there excessive seekg's I can remove? Thanks again! It works!
Thanks, what does clearing an ifstream do?
Just a tip, use the [ code ] tag.
#include <stdio.h>
int main() {
FILE *outp;
char *output_filename;
output_filename = "output.txt";
I opened all the files for both input and output, so that's not the problem. Well here goes...
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
In my program, I am reading in a file ("source" - cannot be overwritten) and copying it to another file ("target") by reading and writing one line at a time. I am manipulating the data found in...
Thanks for your help!
Also, is there any easy way to get the name of the file which the fstream was opened on? That is, given an fstream, can you give me the name of the file the fstream is "pointing to"?
So the following line will erase the contents of a.txt?
fstream target( "a.txt", ios :: out );
What is the quickest way to erase the contents of an fstream? I don't want to delete the file, just make it blank.
Sorry, what I meant was basically "do not open the file if it already exists." I don't want to be able to write to a file if it already exists.
Great, that helps a lot. My only question then is how do I ensure that I am not opening a pre-existing file for output; in other words, I wish to prevent any sort of overwriting. Thanks again!
This is my first post, so please go easy on me ;).
I intend to both read from and write to a file. Can I have an ifstream and ofstream open for the same file at the same time? Or do I have to...