help a noob out

Started by
18 comments, last by GameDev.net 19 years, 7 months ago
Ok i started learning c++ yesterday here is a piece of code i have written, why does it not compile and run, i use borland c++ builder 5 #include <iostream.h> int main () { int x=5; int i; cout << "enter the number five"; cin >> i; if (i==x) cout << "well done!"; else cout << "i said type five dumbass"; return(0); }
Advertisement
Worked fine for me. <iostream.h> is depracated. Use <iostream> and then using namespace std;

#include <iostream>using namespace std;int main (){   int x=5;   int i;   cout << "enter the number five";   cin >> i;   if (i==x)     cout << "well done!";   else     cout << "i said type five dumbass";return(0);}
oh boy...
1) iostream.h is a non-standard header, use iostream.
2) what errors do you get?
#include <iostream>#include <ostream>#include <istream>using std::cin;using std::cout;int main (){	int x = 5;	int i;	cout << "enter the number five";	cin >> i;	if (i==x)		cout << "well done!";	else		cout << "i said type five dumbass";	return 0;}

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

i think it might be my compiler, it says "unresolved external form", any compilers you would recommend?
Hrm, seeing the error would be much more helpful. You could use Visual C++ 2003. Or GCC or DevC++...

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Quote:Original post by Washu
Hrm, seeing the error would be much more helpful. You could use Visual C++ 2003. Or GCC or DevC++...


ok, is devc++ shareware/freeware and what is the difference between iostream.h and iostream?
iostream.h doesn't exist in the context of the standard. iostream does however. DevC++ and variants are free. Visual C++ 2003 is not, but the CLI compiler/linker is.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Yes, dev-C++ is free. Go here to download it. And it would definitely help if you posted what error you're getting, exactly. Chances are somebody else has gotten it.


EDIT: link fixed
Things change.
the link u gave me was incorrect and for the original code i posted do you really need to add the other #includes

EDIT: the #includes i meant were #include <ostream>
#include <istream>
using std::cin;
using std::cout
Quote:Original post by Haku
the link u gave me was incorrect and for the original code i posted do you really need to add the other #includes

Yes, iostream will declare cin and cout, but might not define them in any other regards (most libraries do however).

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

This topic is closed to new replies.

Advertisement