I broke C++!

This is a discussion on I broke C++! within the C++ Programming forums, part of the General Programming Boards category; what does this error mean? [error from hell] --------------------Configuration: lesson1 - Win32 Debug-------------------- Compiling... Lesson1.cpp Linking... Lesson1.obj : error LNK2001: ...

  1. #1
    Shadow12345
    Guest

    I broke C++!

    what does this error mean?
    [error from hell]
    --------------------Configuration: lesson1 - Win32 Debug--------------------
    Compiling...
    Lesson1.cpp
    Linking...
    Lesson1.obj : error LNK2001: unresolved external symbol "void __cdecl FileInputModule(void)" (?FileInputModule@@YAXXZ)
    Debug/lesson1.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    lesson1.exe - 2 error(s), 0 warning(s)
    [/error from hell]

    This happens when I make a call to a function, I don't know why!EDIT:
    neermind i'm an idiot i spelled a function wrong
    Last edited by Shadow12345; 09-30-2002 at 09:50 AM.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >I broke C++!
    Hehe, I enjoyed this title.

    >Lesson1.obj : error LNK2001: unresolved external symbol "void __cdecl FileInputModule(void)" (?FileInputModule@@YAXXZ)
    The body of FileInputModule is not defined anywhere, if it was a function you wrote yourself then you either forgot to write it or didn't include the header file it was defined in. If it is a third party function or standard with your compiler, make sure you are including both the library as well as the header.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Shadow12345
    Guest

    Can you check this code?

    Can you check this code to see if it make sense? I declard the Triangle at global scope because it didn't seem to work inside the function

    The triangle is:
    struct Triangle{
    float a,b,c,d,e,f,g,h,i;
    };

    This code is supposed to read in coordinates from a file until the end of the file is reached. I put a messagebox to signal when it gets to the end of the file so make sure it works, but even with a small number of coordinates it never reaches the end of the file

    note I've tried using fin.good and !fin.eof in the while loop

    Code:
    void InputFileModule(void) {
    
    vector<Triangle*> TriangleVector;
    
    
            ofstream fout;
            ifstream fin;
            fout.open("Formatted coords.txt");
            fin.open("Coordinates.txt");
            if(fout.fail()) {
    		MessageBox(NULL, "Output file initialization failed", "ERROR", MB_OK);
                    return;
            }
    
            if(fin.fail()) {
    		MessageBox(NULL, "Input file initialization failed", "ERROR", MB_OK);
                    return;
            }
    
            int x = 0;
    
            while(fin.good()) {
            TriangleVector.push_back(new Triangle);
            fin.ignore(2, NULL);
            fin >> TriangleVector[x]->a;
            fin >> TriangleVector[x]->b;
            fin >> TriangleVector[x]->c;
            fin.ignore(5, NULL);
            fin >> TriangleVector[x]->d;
            fin >> TriangleVector[x]->e;
            fin >> TriangleVector[x]->f;
            fin.ignore(5, NULL);
            fin >> TriangleVector[x]->g;
            fin >> TriangleVector[x]->h;
            fin >> TriangleVector[x]->i;
            fout << TriangleVector[x]->a << endl;
            fout << TriangleVector[x]->b << endl;
            fout << TriangleVector[x]->c << endl;
            fout << TriangleVector[x]->d << endl;
            fout << TriangleVector[x]->e << endl;
            fout << TriangleVector[x]->f << endl;
            fout << TriangleVector[x]->g << endl;
            fout << TriangleVector[x]->h << endl;
            fout << TriangleVector[x]->i << endl;
    		fin.seekg('\n');
    		fin.seekg(1);
            x++;
            }
           
    			MessageBox(NULL, "File Initialization Successful", "Success", MB_OK);
    
    
            fin.close();
            fout.close();    
    }
    EDIT:
    I tried putting
    struct Triangle {
    float a,b,c,d,e,f,g,h,i;
    };
    in the InputFileModule function and i get 20 errors !

  4. #4
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    I like this as well:

    >I broke C++!
    Hehe, I enjoyed this title.


    How about "The computer is giving me attitude again."

    Anyway, Prelude has you on the right track.

  5. #5
    Shadow12345
    Guest
    The part Prelude answered to is fixed, but I am still having problems. The code I posted above compiles and runs but never signals that it completed and I don't know why.

    Here is what is being inputted:
    ( 560 -680 -272 ) ( 560 -504 -272 ) ( 720 -504 -272 ) TSNOSKD [ -1 0 0 128 ] [ 0 1 0 24 ] 0 1 1
    ( 576 -504 -296 ) ( 576 -680 -296 ) ( 704 -680 -296 ) TSNOSKD [ -1 0 0 128 ] [ 0 1 0 24 ] 0 1 1
    ( 720 -504 -272 ) ( 704 -504 -296 ) ( 704 -680 -296 ) TSNOSKD [ 0 -1 0 -120 ] [ 0 0 -1 0 ] 0 1 1
    ( 576 -504 -296 ) ( 560 -504 -272 ) ( 560 -680 -272 ) TSNOSKD [ 0 -1 0 -120 ] [ 0 0 -1 0 ] 0 1 1
    ( 720 -680 -272 ) ( 704 -680 -296 ) ( 576 -680 -296 ) TSNOSKD [ -1 0 0 128 ] [ 0 0 -1 0 ] 0 1 1
    ( 704 -504 -296 ) ( 720 -504 -272 ) ( 560 -504 -272 ) TSNOSKD [ -1 0 0 128 ] [ 0 0 -1 0 ] 0 1 1

    The idea is that once it gets to the last parenthesis it just goes to the next line

  6. #6
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    *inspects error*

    Yup, ya broke C++! And I needed to use it to! Thanks alot!!

  7. #7
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    are you sure it's reading in anything? Try putting in a

    cout << Trianglevector[x]->i;
    char ch;
    cin >> ch;

    after the call fin...->i;

    to see that you made it that far at least.

    If that works then look up syntax for seekg. I think it takes an offset, not a terminating char, but I don't use it and can't say for sure. I would use:

    cin.getline(dummy, 80, '\n');

    instead of seekg() to ignore the remainder of the line if you read all the way to i successfully.

  8. #8
    Shadow12345
    Guest
    Yes I had a console version of the same code and it printed all of the correct values to the screen and it even wrote it to a new file, but, lo and behold it doesn't work when I move to non console

    Also what is an offset exactly?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ofstream... broke as a result of ifstream fix
    By tms43 in forum C++ Programming
    Replies: 3
    Last Post: 11-12-2006, 10:40 AM
  2. hmm i think i broke something (power supply)
    By MisterSako in forum Tech Board
    Replies: 1
    Last Post: 02-11-2006, 10:32 PM
  3. Logitech MOMO wheel broke, fixed manually
    By Xei in forum Tech Board
    Replies: 2
    Last Post: 07-25-2003, 02:29 AM
  4. how can you tell if you broke your toe?
    By mithrandir in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 01-25-2002, 12:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21