# problem with Dev-C++ & main()

This is a discussion on problem with Dev-C++ & main() within the C++ Programming forums, part of the General Programming Boards category; am watching *Compiling & Executing Programs Demo* at http://www.computer-training-software.com/c.htm and i stumbled upon this Code: 1 C:\Dev-Cpp\include\c++.4.2\backward\iostream.h:31, from C:\Dev-Cpp\test\Untitled1.cpp In ...

1. ## problem with Dev-C++ & main()

am watching *Compiling & Executing Programs Demo* at
http://www.computer-training-software.com/c.htm
and i stumbled upon this
Code:
1 C:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31,               from C:\Dev-Cpp\test\Untitled1.cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31,               from C:\Dev-Cpp\test\Untitled1.cpp
1 C:\Dev-Cpp\test\Untitled1.cpp                  from C:\Dev-Cpp\test\Untitled1.cpp
32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #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 <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
4 C:\Dev-Cpp\test\Untitled1.cpp main' must return int'
C:\Dev-Cpp\test\Untitled1.cpp In function int main(...)':
16 C:\Dev-Cpp\test\Untitled1.cpp end1' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
this is my code
Code:
#include <iostream.h>

void main()
{
float num1;
float num2;
float total;

cout << "Enter a value for this first virable: ";
cin >> num1;
cout << "Enter a value for this first virable:  ";
cin >> num2;

total = num1 + num2;

cout << "The sum of the numbers = " << total << end1;

}

2. The manipulator is endl (as in line) not end1 (as in one). Also main should be declared as an int, not void. Other than that, you're just getting deprecated warnings on your library. At this point you might want to ignore that for now until your get a grasp on the basics.

3. Do exactly as the compiler tells you. main returns an int. You have it written as returning void which has no advantage whatsoever.

Also, iostream.h is old.
#include <iostream>

Everything else looks fine to me, except after you include that you should also type
uning std::cout;
using std::endl;

4. It's not virable, it's variable

5. its not my fault that the man in the turtuial is using a old iostream

6. .... He's not going to teach you to use gets() is he?

I was watching this. He keeps referring to C++ as C (and even the compiler as C), which is going to confuse people. You and all of his students need to make the distinction quickly that C is not C++, and a compiler is not C either. I want to recommend that you stop watching these immediately and that they are taken off the internet, but alas I cannot do anything that drastic.

This poor unfortunate soul.

7. thanks guys
finly i got the sample calc working <3

8. but it wont stay there it closes right after i inputs numbers
hmm

9. The instructor said that endl will pause the console. I actually haven't had very much experience with the old iostream.h, but I think that he is very wrong about that. You should also not rely on whether or not he is right. endl simply puts a newline onto the screen and then "flushes" the output buffer.

There are a couple of things you can do to see the output of your program.
- My personal favorite, run the program in a console you opened yourself. That way, the console will not close until you type exit. Just drag and drop your executables into the console window.
- You could pause the program with something like
cin.ignore();
cin.get();
Where ignore will grab a newline that might be in the input buffer, and get will wait for more input before closing the program. Just press enter to close. Beware though, sometimes more than one character will be in the input stream and modifications will need to be made to ignore(). This is one of the reasons why I like running my programs from my own console window.

10. Or switch to Visual C++ or Code::Blocks, both of which are smart enough to automatically run console apps in a small wrapper application that keeps the console open.

11. Originally Posted by CornedBee
Or switch to Visual C++ or Code::Blocks, both of which are smart enough to automatically run console apps in a small wrapper application that keeps the console open.
nah i wont use Micro$oft Visual C++, also it uses like 2GB space and Dev-C++ used 65MB gonna check out code:blocks now 12. Originally Posted by wiak nah i wont use Micro$oft Visual C++, also it uses like 2GB space and Dev-C++ used 65MB
gonna check out code:blocks now
That's the entire .NET framework taking up that space. As well as all their other utilities for C#, J#, etc... If you aren't limited on disk space, I'd recommend installing all the compilers you can get your hands on, so long as they're standard.