Saturday, May 9, 2009

C++ Help!!!?

I have a final due pretty soon, and I need to work on it at home. But i cannot find any C++ Programs that program anything similar to the one we use in class.





For example, ussually the header we use is





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





and using:





cout %26lt;%26lt; "Example" %26lt;%26lt; '\n';





All the other C++ programs i found were all way diffrent, PLEASE help me T.T

C++ Help!!!?
All first three answerers are right! You are actually using the old compiler. I am using the old compiler. But you need not to worry because the more it is improved, the better. There are slight changes in the new compiler like the loss of .h extension to all library header files, the use of namespace, the presence of vector (I think vector is cool compared to array) and so many more...
Reply:the program you are writing should be :





#include %26lt;iostream%26gt; // provide input and output


#include %26lt;cstdlib%26gt; // provide standard library





using namespace std;





//main driver start


int main (){


cout %26lt;%26lt; "Example \n"; //print the the word "Example " \n to newline.


return EXITSUCCESS;


} //end program





from


keng ping kong from www.iwohoo.com and www.pinkeikong.com
Reply:%26lt;iostream.h%26gt; will compile with gcc2.95.* compilers


You just have to choose the right compiler or else use %26lt;iostream%26gt;
Reply:thats because the compiler is old as crap... i ran into the same problem when i upgrade my compiler.
Reply:You can use the gcc program that comes with cygwin, and add the option -Wno-deprecated when compiling -- and it will support the code like you have shown above.





Cygwin is a free product, available at www.cygwin.com





When installing, you will need to install the gcc/g++ compiler option under "development".





For example, let's say you create this program named "example.cpp" in C:\ using notepad:





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


using namespace std;





int main()


{


cout %26lt;%26lt; "Example";


return 0;


}





Once you start cygwin by clicking on the icon, you will navigate to where you saved your file:





cd /cygdrive/c





Then you will compile:





gcc -Wno-deprecated example.cpp -o test.exe





And now you can run test.exe:





./test.exe





That should be all you need.


No comments:

Post a Comment