Thread: Data I/O Problems

  1. #1
    Registered User Led4urhead123's Avatar
    Join Date
    Jul 2008

    Data I/O Problems

    This is part of a much larger code but its supposed to do in steps
    1]use ifstream take text from a user-specified file
    2]store that text as a string
    3]close ifstream and use ofstream to export the string to another file
    I have a problem because I've tested it a bunch of times but the string seems to never get saved to the new file.

    //*******************DATA CONVERSION******************
        if(ans == 3){
               ans = 0;
               cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
               //Reading Data
               ifstream inputFile;
               cout<<"Data File Name: "; cin>>filename;
    	       cout << "\nReading Data From " << filename << "...\n";
    	       inputFile.getline(data_input, 1000);
    	       //write to data to new file
    	       cout<<"Output Data To File: "; cin>> exportfilename;
    	       ofstream outputFile(exportfilename, ios::app);
               cout << "\nWriting To " << exportfilename << "...\n";
               outputFile << data_input;
               goto main;

  2. #2
    Registered User
    Join Date
    Mar 2007
    Quote Originally Posted by Led4urhead123 View Post
    	       ofstream outputFile(exportfilename, ios::app);
    Not sure if this is a direct cause, but you are essentially trying to open the same file twice on the output file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. I/O and Array Problems
    By carrotcake1029 in forum C Programming
    Replies: 4
    Last Post: 04-08-2008, 04:53 AM
  3. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  4. pipe stream data I/O
    By vector7 in forum Linux Programming
    Replies: 1
    Last Post: 03-11-2003, 06:46 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM