GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Apr-2006, 14:14
earachefl earachefl is offline
Member
 
Join Date: Feb 2006
Posts: 178
earachefl is on a distinguished road

Basic file copy question


I'm trying to input an example from my textbook:
CPP / C++ / C Code:
//File: copyFile.cpp
//Copies file InData.txt to file OutData.txt
#include <iostream>
#include <cstdlib>              //for the definition of EXIT_FAILURE
#include <fstream>
using namespace std;

//Associate stream objects with external file names
#define inFile "/Users/me/Documents/ COMSCI101/C8L8.3 file copy/InData.txt"
#define outFile "/Users/me/Documents/ COMSCI101/C8L8.3 file copy/OutData.txt"

//Functions used . . .
//Copies one line of text
int copyLine(ifstream&, ofstream&);

int main () 
{
    int lineCount;
    ifstream ins;
    ofstream outs;
    
    //char buffer[1000];
    //std::cout << "Current directory is: " << getcwd(buffer, 1000) << "\n";
    
    
    //Open input and output file, exit on any error
    ins.open(inFile);
    if (ins.fail())
    {
        cerr << "*** ERROR: Cannot open " << inFile << " for input." << endl;
        return EXIT_FAILURE;
    }
    
    outs.open(outFile);
    if (outs.fail())
    {
        cerr << "*** ERROR: Cannot open " << outFile << " for output." << endl;
        return EXIT_FAILURE;
    }
    //cout << "files opened" << endl;

    //Copy each character from inData to outData
    lineCount = 0;
    while (!ins.eof())
    {
        if(copyLine(ins, outs) != 0)
            lineCount++;
    }
    
    cout << "Input file copied to output file." << endl;
    cout << lineCount << " lines copied." << endl;
    
    ins.close();
    outs.close();
    
    return 0;
}
The code compiles and runs, and seems to open the files, but I get the following error messages:
Quote:
ZeroLink: unknown symbol '__Z8copyLineRSt14basic_ifstreamIcSt11char_traitsI cEERSt14basic_ofstreamIcS1_E'

C8L8.3 file copy has exited due to signal 6 (SIGABRT).
I admit, I have no idea what's happening here......

I'm on a Mac, using XCode 2.2. The InData.txt and OutData.txt are blank text documents created in Word.

TIA for your help.
  #2  
Old 13-Apr-2006, 14:38
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,720
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Basic file copy question


Quote:
Originally Posted by earachefl
The code compiles and runs, and seems to open the files, but I get the following error messages:
Quote:
ZeroLink: unknown symbol '__Z8copyLineRSt14basic_ifstreamIcSt11char_traitsI cEERSt14basic_ofstreamIcS1_E'

C8L8.3 file copy has exited due to signal 6 (SIGABRT).

I admit, I have no idea what's happening here......

Where is the function copyLine()? It's declared but not defined in the file that you showed. Did you try to link it in, somehow? It looks to me as if the error message is from the linker, trying to find it. (C++ implementations augment function names in order to give information about parameters and return types.)

Regards,

Dave
  #3  
Old 13-Apr-2006, 14:46
earachefl earachefl is offline
Member
 
Join Date: Feb 2006
Posts: 178
earachefl is on a distinguished road

Re: Basic file copy question



D'oh!!! it might help if I input the entire example, not just main().........


Well, at least it works!!!

Thanks Dave!
 
 

Recent GIDBlogDeveloping GUIs with wxPython (Part 2) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 07:44
CD Burner Help - Power Calibration Error.... JonBoy420 Computer Hardware Forum 110 05-Feb-2008 18:34
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 10:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28
Can't view pages from another machine on the Intranet aevans Apache Web Server Forum 9 14-May-2004 02:26

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:46.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.