C/C++ >> visual c++
Posted by Tatchster on 19:45:00 10-12-2002
I just began using visual c++ and found it very different to normal c++
can someone tell me how to read a file and what to #include?
coz normal ifstream does not work
Posted by gian on 21:27:00 10-12-2002
Visual C++ implements the C++ standard, so go figure on that one...

try iostream.h

If it doesn't work, I would imagine that you do not have your directories set correctly.

[ This Message was edited by: gian on 2002-10-12 21:28 ]
Posted by KaGez on 22:30:00 10-12-2002
http://www.youngprogrammers.net/showdoc.php?id=4

Do you mind using the search engine next time?
[addsig]
Posted by Neu[Mann] on 23:35:00 10-12-2002
Microsoft Visual C++ 6.0 does not implement the full C++ standard. That may cause some problems. I'd say it's mostly standard but you could find some quirks once in a while. In the other hand, Visual C++.NET does.
Posted by ItinitI on 23:36:00 10-12-2002
Hello Gian! It's been a while since I'v heard from you. Have you heard from RDD lately? [addsig]
Posted by Tatchster on 10:18:00 10-13-2002
Ive done what the tutorial says and when i compile it there is no errors
However when i try to build the object i egt some weird errors like inappropriate types used
the basic sample for my code is


#include
#include

LPTSTR filename;
filename = "inputfile.txt";
ifstream file;
file.open(filename);

LPTSTR header, colour;
int width, height;
file -->--> header;
file -->--> width;
file -->--> height;
file -->--> colour;

file.close();
the errors i get are

error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall ifstream::`vbase destructor'(void)" (__imp_??_Difstream@@QAEXXZ)
ezrgb24.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall ifstream::close(void)" (__imp_?close@ifstream@@QAEXXZ)
ezrgb24.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall ios::eof(void)const " (__imp_?eof@ios@@QBEHXZ)
ezrgb24.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class istream & __thiscall istream::operator-->-->(int &)" (__imp_??5istream@@QAEAAV0@AAH@Z)
ezrgb24.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class istream & __thiscall istream::operator-->-->(char *)" (__imp_??5istream@@QAEAAV0@PAD@Z)
ezrgb24.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall ifstream::open(char const *,int,int)" (__imp_?open@ifstream@@QAEXPBDHH@Z)
ezrgb24.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static int const filebuf::openprot" (__imp_?openprot@filebuf@@2HB)
ezrgb24.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall ifstream::ifstream(void)" (__imp_??0ifstream@@QAE@XZ)
.\Debug\ezrgb24.ax : fatal error LNK1120: 8 unresolved externals



can anybody enlighten me on what i am doing wrong or what the erros mean?
Posted by buzgub on 12:47:00 10-13-2002
I suspect that your project is not being linked against the iostreams library.
Posted by KaGez on 22:32:00 10-13-2002
if you really compile the exact code as it is above (or better, in the HTML sources, since the include's will diasappear in HTML ) the stuff won't compile for sure afaik. I think you will need to put the code into a function called main() at least. Afaik nothing will work without a main() (WinMain or something like that in WinAPI).
But, that's just the case if you use the exact code as it is above
[addsig]
Posted by Neu[Mann] on 05:44:00 10-14-2002
Kage: Those are linker errors. Nothing to do with is code not being in the 'main' method [addsig]
Posted by Tatchster on 06:13:00 10-14-2002
Its nothing to do with the main coz that code portion is inside a routine and runs without it. But when i add that part of the code in it just comes up with the errors.
Just thought maybe i was using fstream.h incorrectly.
Posted by KaGez on 11:22:00 10-14-2002
how should I know that? you just said that you've started C++, and sometimes it just happens that you leave out the main func
[addsig]
Posted by dxprog on 02:12:00 10-15-2002
I think KaGez is right. [addsig]
Posted by KaGez on 17:29:00 10-15-2002
I am _always_ right!
(except when I'm wrong )
[addsig]
Posted by DimSum on 05:48:00 10-30-2002
If you're using visual C++ for file I/O, CFile or CStdioFile are eaiser to use.
Posted by KaGez on 14:15:00 10-30-2002
it will limit the portability of the code _extremely_ tho.
[addsig]
Posted by neonbjb on 16:33:00 01-03-2003
what kind of project is it that ur compiling?
Posted by neonbjb on 15:46:00 02-02-2003
Being a fellow VC++ jockey, (I dont get the fricken 'portability' thing and dont correct me Kagez) you first have to tell us what kind of project ur compiling. You should be doin a win32 console project, but for all i know, your compiling it through the console (you arnt are you?)