#### Archived

This topic is now archived and is closed to further replies.

# Trouble compiling in Dev C++

## Recommended Posts

#include <iostream.h> void main () { cout << 10 % 8 << endl; } --Having trouble compiling the program above. I''m new to Dev C++ and any help would be appreciated. After I compile the program a tab for iostream.h pops up and the errors are as follows... 31 C:\Dev-Cpp\include\c++\backward\iostream.h In file included from C:/Dev-Cpp/include/c++/backward/iostream.h 1 C:\Documents and Settings\Nelson Marques\Desktop\test.cpp from C:/Documents and Settings/Nelson Marques/Desktop/test.cpp 2 C:\Dev-Cpp\include\c++\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated. 4 C:\Documents and Settings\Nelson Marques\Desktop\test.cpp main'' must return --NM

##### Share on other sites
Use of the old-style .h headers is deprecated. use #include < iostream > instead.

Also, declare main as:

int main()

or

int main(int argc, char *argv[])

rather than void.

Josh
vertexnormal AT linuxmail DOT org

Check out Golem at:
My cheapass website

[edited by - VertexNormal on September 3, 2003 7:48:02 PM]

##### Share on other sites
thanx josh, it seems simple to you but your help saved me alot of time

--NM

Any time.

##### Share on other sites
Also remember that the new style headers use namespaces, so you either have to put "using namespace std;" to use cout, or you can use the scope resolution operator as in "std::cout << 10 % 8 << endl;"

##### Share on other sites
actually, now i''m getting a few different errors... here they are...

C:\Documents and Settings\Nelson Marques\Desktop\Untitled1.cpp
[Warning] In function:

5 C:\Documents and Settings\Nelson Marques\Desktop\Untitled1.cpp
cout''

5 C:\Documents and Settings\Nelson Marques\Desktop\Untitled1.cpp
(Each

5 C:\Documents and Settings\Nelson Marques\Desktop\Untitled1.cpp
endl''

##### Share on other sites
ok thanks again, just saw your post after i posted mine

##### Share on other sites
#include <iostream>

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

Ok, the above program still getting these errors..

C:\Documents and Settings\Nelson Marques\Desktop\Untitled1.cpp
[Warning] In function:

5 C:\Documents and Settings\Nelson Marques\Desktop\Untitled1.cpp
endl''

5 C:\Documents and Settings\Nelson Marques\Desktop\Untitled1.cpp
(Each

##### Share on other sites
I'm sorry, i forgot about endl. If you don't use namespaces, you have to use scope resolution for all objects you use from other libraries, and that includes endl. Try this:

#include <iostream>

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

[edited by - Vikato on September 3, 2003 8:05:45 PM]

##### Share on other sites
using namespace std seems a lot more effective IMHO.

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

##### Share on other sites
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..

##### Share on other sites
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

##### Share on other sites
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]

##### Share on other sites
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]

##### Share on other sites
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]

##### Share on other sites
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 ]

• ### Forum Statistics

• Total Topics
628354
• Total Posts
2982243

• 10
• 9
• 11
• 24
• 11