Sunday, August 2, 2009

Programming in Dev C++...Please Help?

I know C++ programming in Turbo C++.


But my same source codes from Turbo C++ are not working in Dev C++


Are the codes in Dev C++ different?





In turbo i wrote


#include%26lt;iostream.h%26gt;





but when i write the same thing in Dev C++ it jus doesn't accept it.

Programming in Dev C++...Please Help?
C++ libraries don't use .h anymore. Some compilers still support .h C++ includes, but most don't anymore.





Instead of





[code]


#include %26lt;iostream.h%26gt;


[/code]





You will have to use





[code]


#include %26lt;iostream%26gt;





using namespace std;


[/code]





If you don't know what a namespace is, you better google it, but to put it short, the C++ objects are into the std namespace, so you will have to either type that, or to type std:: before each object.





For example: std::cout %26lt;%26lt; "hello world";





(However as I said, "std::" is not necessary if you type "using namespace std;" in the start, becuase you tell the compiler the default namespace is std).








Other C++ includes are:


%26lt;vector%26gt; %26lt;string%26gt; %26lt;ctime%26gt; %26lt;cmath%26gt; (...)





As you can see, the names are the same, but without a .h and into the namespace std.
Reply:To see the output you could pause the program.


Try adding a "system("pause");" statement before the return.





Note that the function system() is basically Windows only. Report It

Reply:you can run your application through the DOS console:


go to start%26gt;run%26gt;cmd you will go to dos mode


then write the applicaiton name (ie. .exe), the result will be the following lines so no need to pause the system. Report It

Reply:Also instead of system("PAUSE"), you could put cin.get();





It makes you press enter to exit, and works good in Hello world, but if you want to create something that has input, I recommend using system("PAUSE"), its just that you never know if cin.get(); will work with input... Report It

Reply:It might accept





# include%26lt;iostream%26gt;
Reply:i have same problem can u help to find turbo C++ pls my ID is grubb128 now i'm online pls help me%26gt;%26gt;%26gt;

morning glory

No comments:

Post a Comment