• 0

[C++] Help


Question

Right i started learning C++ about 3 days ago with the boot C++ All - In - One Desk Refernce for Dummies.

On the CD with it, it came with a compiler which was Bloodshed Dev-C++. I dont know if it is me or the compiler but i have error with my code that i used from the book:

#include <iostream>

#include <stdlib.h>

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

{

int mynumber;

mynumber = 10;

cout << mynumber << end1;

system("PAUSE");

return 0;

}

It is very basic but Dev-C++ is telling me that "Line 7 `end1' undeclared (first use this function)"

So yeh anyhelp, do i have end1 typed in wrong or is it the compiler????

Thanks

dave164

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

yeh , endl means endline, would be strange endl1, that 1 doesnt stand for anything, anyway goodluck with your c++ study, feel free to ask anymore question here around :)

Link to comment
Share on other sites

  • 0

thanks yeh i most likely will, its quite interesting really :p

I primely started to learn C++ to make media players, IE's and cool windows programs, maybe a few other tools to :shifty:

Link to comment
Share on other sites

  • 0
#include <iostream>

#include <stdlib.h>

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

{

  int mynumber;

  mynumber = 10;

  cout << mynumber << end1;

  system("PAUSE");

  return 0;

}

Aside from the end1 mistake, this example should NOT work (and won't) on most C++ compilers as the namespace std is never included in the global scope.

Also, don't use tricks such as system("PAUSE"); it's not portable, and avoid using C library such as "stdlib.h", if you must use it use "cstdlib" instead (which is the C++ header for stdlib.h).

Last thing, "return 0;" is implicit and not mandatory for the main in C++.

#include &lt;iostream&gt;
using namespace std;

int main()
{
    const int mynumber = 10;
    cout &lt;&lt; mynumber &lt;&lt; endl;
    cout &lt;&lt; "Press enter to continue." &lt;&lt; endl;
    cin.get();
}

If you're serious about C++ programming, I suggest you ditch Dev-C++ and use a real and uptodate C++ compiler such as Visual C++ 7.1 or GCC 3.4.

Link to comment
Share on other sites

  • 0

Dev-C++ is not a compiler, it's an IDE that relies on some version of GCC (the stable version 4 ships with GCC 2.95 released 4 years ago).

I mus say I find Dev-C++ to be more than very suspicious, it's not the first time I see it accepting erronous code.

If you want to code with GCC for C++, at least get the last version (3.4.1 at this time). For C++, it's already night and day between the 3.3 and the 3.4, I let you think what it is with the 2.95.

As for a good C++ IDE under Windows, nothing comes close to Visual C++ 7.1 or higher: VC++ 8.0 Express Edition Beta 1 is available for free on MS website, VC++ 7.1 Professional is for sale at a fair price, and well, nobody cares if you get it by other means.

The reason I wouldn't like someone to use Dev-C++ is that it will give you bad habits and teach you an incorrect C++.

So do you want to really learn the Standard C++ or some language that merely looks like it and only compiles on Dev-C++?

Link to comment
Share on other sites

  • 0

how on earth does dev c++ give you bad habits. even the old version od mingw gives you less bad habits than VC++ does.

Just get Dev-C++ 5 from the site, it comes with the newer version of mingw, it looks good and is good, and theres only a few buggs left to be sorted but they dont interfear with your codeing.

Link to comment
Share on other sites

  • 0

The ANSI/ISO C++ standard (ISO/IEC 14882:1998, aka: C++98) doesn't use __asm ... it uses asm (this is an example). I have used VC++ 7 and I notice it is way too forgiving. GCC follows the standard. I downloaded VC++ 8.0 Express Ed. Beta1 and it seems to be a lot better than before.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.