|
-
March 15th, 2005, 11:58 AM
#1
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
-
March 15th, 2005, 12:12 PM
#2
Re: ambiguous Symbol
try include
#include <fstream>
instead of
#include <fstream.h>
-
March 15th, 2005, 12:47 PM
#3
Re: ambiguous Symbol
 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
-
March 15th, 2005, 09:52 PM
#4
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
-
March 15th, 2005, 11:19 PM
#5
Re: ambiguous Symbol
would you please write the whole code/program
-
March 16th, 2005, 01:25 AM
#6
Re: ambiguous Symbol
Are you sure that you have a main() in your program?
-
March 16th, 2005, 05:40 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|