CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2005
    Posts
    120

    ambiguous Symbol

    Hi,

    i Have the following code:

    using namespace std;
    char str[2000];
    string file = "foo.txt";
    char* cwd = getcwd(NULL, 0);
    string path = cwd;
    free(cwd);
    (path += "/") += file;
    fstream file_op(path.c_str(), ios::in);
    file_op.getline(str,1999);
    file_op.close();

    problem is i am getting an error during compile:

    error C2872: 'fstream' : ambiguous symbol


    i searched and i found that it might have something to do with headers. These are the headers i used:


    #include <windows.h>
    #include <fstream.h>
    #include <direct.h>
    #include <string>

    (note that the above is only a portion of the full code)


    anyone know what is causing the error? thanks

  2. #2
    Join Date
    Jun 2004
    Location
    Brazil
    Posts
    25

    Re: ambiguous Symbol

    try include
    #include <fstream>
    instead of
    #include <fstream.h>

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: ambiguous Symbol

    Quote Originally Posted by goobers
    i searched and i found that it might have something to do with headers. These are the headers i used:

    #include <windows.h>
    #include <fstream.h>
    Do not mix up non-standard headers with standard headers. Always use the standard headers (the headers with no .h).

    Corrections:
    Code:
    #include <fstream>  // no .h
    Regards,

    Paul McKenzie

  4. #4
    Join Date
    Feb 2005
    Posts
    120

    Re: ambiguous Symbol

    hi,

    that worked.. but now i am getting different errors during linking:


    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/main.exe : fatal error LNK1120: 1 unresolved externals

  5. #5
    Join Date
    May 2003
    Location
    Islamabad, Pakistan
    Posts
    284

    Re: ambiguous Symbol

    would you please write the whole code/program

  6. #6
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    Re: ambiguous Symbol

    Are you sure that you have a main() in your program?

  7. #7
    Join Date
    Feb 2005
    Posts
    120

    Re: ambiguous Symbol

    I included tchar.h and it worked fine.. i wonder why ..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured