Trouble compiling in Dev C++

Started by
14 comments, last by vassago74 20 years, 7 months ago
i agree, thx for the help guys. i was putting the line "using namespaces std" on the same line as #include <iostream> and it wasn''t working, but got it now. thanks again..
--NM
Advertisement
hi, kinda new here,
i copied
#include <iostream>

int main ()
{
std::cout << 10 % 8 << std::endl;
}

and when i run the program, the dos window opens but closes right away, so i cant read anything on the screen, why is this? thanks
to make it stay on the screen you can use

system("pause");//need to include the stdlib I believe


Another way is to use

   getch();//this one needs to have conio included at the top


And yet another way is to run your executable file with this

cmd /k executable file here     
the /k switch here ensures that the dos window remains open after execution is complete. So take your pick




--{You fight like a dairy farmer!}

[edited by - greatwolf on September 5, 2003 2:19:54 AM]

--{You fight like a dairy farmer!}

The program closes because it reaches the end of main you have to make it "wait" for your input or something like that or it will close use this code instead..


#include <iostream>

int main ()
{
std::cout << 10 % 8 << std::endl;
system("PAUSE"); //wait until you press a key
}

EDIT: heh never mind Greatwolf beat me, I can't type that fast

[edited by - FtMonkey on September 5, 2003 2:24:42 AM]
The monkeys are listening...
wow thanks a lot, u guys are great


one more thing, i get
error LNK2001: unresolved external symbol _main
a lot, and ive searched here and im not quite sure i understand how to fix it. can you help?

[edited by - soonk on September 5, 2003 2:29:08 AM]
quote:Original post by sSimontis
using namespace std seems a lot more effective IMHO.

Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis

Well, no, because you cause the global namespace pollution to reappear.

[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]

This topic is closed to new replies.

Advertisement