Dev-C++ problem

A long while ago I used to program with and older version of bloodsheds dev-c++ and have come back and downloaded the newest beta version. I seem to have gotten lost some were in the old code syntax, I wrote the old "hello world" program and got 72 bugs. whats wrong with me!!?!...

#include
using std::cout;
using std::cin;
int main()

{
cout << "Hello ! This is a console app."
cout << "To create a console, go to Project Options and select"
cout << "'Win32 Console'."
cout << "Press q to quit "
cin >> quit;
}

Comments

  • : A long while ago I used to program with and older version of bloodsheds dev-c++ and have come back and downloaded the newest beta version. I seem to have gotten lost some were in the old code syntax, I wrote the old "hello world" program and got 72 bugs. whats wrong with me!!?!...
    :
    : #include
    : using std::cout;
    : using std::cin;
    : int main()
    :
    : {
    : cout << "Hello ! This is a console app."
    : cout << "To create a console, go to Project Options and select"
    : cout << "'Win32 Console'."
    : cout << "Press q to quit "
    : cin >> quit;
    : }
    :
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Not sure if it's a feature of dev-c++ or not (I've never used it), but shouldn't all of your code lines end in a semi colon?

    Even with that adjustment, all of your out put will print on one line unless you add some "
    " s

  • : A long while ago I used to program with and older version of bloodsheds dev-c++ and have come back and downloaded the newest beta version. I seem to have gotten lost some were in the old code syntax, I wrote the old "hello world" program and got 72 bugs. whats wrong with me!!?!...
    :
    : #include
    : using std::cout;
    : using std::cin;
    : int main()
    :
    : {
    : cout << "Hello ! This is a console app."
    : cout << "To create a console, go to Project Options and select"
    : cout << "'Win32 Console'."
    : cout << "Press q to quit "
    : cin >> quit;
    : }
    :

    Well I think if your going to use cout like that you need to end each line with a ';'. You also need to declare 'quit' as some type, like 'char *quit;' before you can use it, and you also need a return statement at the end of the function 'return 0;'. Hope this helps.
  • Well, I lost touch with all the basic skills I had so I'm going to start all over again, I made this a little simpler...

    #include
    using std::cout;
    int main()
    {
    cout<<"hello, how are you all?";
    }

    Now I was wondering what was wrong with this? I know there isn't a return, it's because I can't remember how to write it. Were can I go to get the most up to date lessons? got any good books I should read?
  • [b][red]This message was edited by mrbroph at 2002-12-16 15:35:18[/red][/b][hr]
    : Well, I lost touch with all the basic skills I had so I'm going to start all over again, I made this a little simpler...
    :
    : #include
    : using std::cout;
    : void main()
    : {
    : cout<<"hello, how are you all?";
    : }
    :
    : Now I was wondering what was wrong with this? I know there isn't a return, it's because I can't remember how to write it. Were can I go to get the most up to date lessons? got any good books I should read?
    :
    You were missing the .h from the header declaration and and if main doesnt need to return a value just use void. As for books it depends how much you know i suppose, i would probably reccomend First Course in C++, Harman and jones. or just get yourself a Samms teach yourself book i find they are pretty handy for the basics. A bit more advanced for the OOP side of things your looking at something like C++ How to Program, Deitel and Deitel. hope this helps


  • Okay I retyped in what you put for the fix and I got five bugs. Maybe it's the compiler that is all screwed up. Here is what I put and the errors that it gave me.

    : #include
    : using std::cout;
    : void main()
    : {
    : cout<<"hello, how are you all?";
    : }

    1)Iosteam.h is no such file or directory
    2)Main must return
    3)cout undeclared
    4)in function int main(...)
    5)build error(because of other bugs I assume)
  • : Okay I retyped in what you put for the fix and I got five bugs. Maybe it's the compiler that is all screwed up. Here is what I put and the errors that it gave me.
    :
    : : #include
    : : using std::cout;
    : : void main()
    : : {
    : : cout<<"hello, how are you all?";
    : : }
    :
    : 1)Iosteam.h is no such file or directory
    : 2)Main must return
    : 3)cout undeclared
    : 4)in function int main(...)
    : 5)build error(because of other bugs I assume)
    :
    Not very surprising as this
    #include<iostream>
    using std::cout;
    int main()
    {
    cout<<"hello, how are you all?";
    }

    is a 100% correct program, and the advice mrbroph gave you was poor. If the program above isn't working then you've likely made a mistake installing or using the IDE. Perhaps you should list the errors you are getting with THIS program. Also, when you list errors list the actual text (copy and paste it), don't abbreviate it.


    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

  • : You were missing the .h from the header declaration and and if main doesnt need to return a value just use void.

    Since you seem to be giving this advice a lot, I thought I might as well set you straight about this.

    In Standard C++, iostream.h does not exist (same for other "standard" header files, e.g. ctype.h) instead it IS iostream with no .h. All C headers are prefixed with c so stdio.h becomes cstdio, ctype.h becomes cctype. (Consequently there is now cstring, string, and string.h) Most relatively new compilers support this. When you use them you'll need a using declaration. Usually for a small driver program a using namespace std; suffices.

    As for main starting with void. That is non-standard C or C++ (to whoie: ignoring freestanding implementations ;). It never was standard (though it was legal in C). Most compilers allow it for backwards compatibility with old programs, however, new programs shouldn't use it. There are only two valid C++ entry points:
    int main()
    and
    int main(int argc, char **argv) //or the equivalent char *argv[]

    In Standard C++ if you don't want to return something from main, simply don't. A successful return value will automatically be added if one isn't provided by the user. So the smallest legal C++ program is:
    int main(){}

    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

  • These are the exact errors, copy and pasted.

    21 C:My Documentsfirst.cpp:1
    iostream.h: No such file or directory.

    2 C:My Documentsfirst.cpp
    `cout' not declared

    4 C:My Documentsfirst.cpp
    `main' must return `int'

    C:My Documentsfirst.cpp
    [Warning] In function `int main(...)':

    5 C:My Documentsfirst.cpp
    `cout' undeclared (first use this function)


    [Build Error] (Each undeclared identifier is reported only once


  • : These are the exact errors, copy and pasted.
    :
    : 21 C:My Documentsfirst.cpp:1
    : iostream.h: No such file or directory.
    :
    : 2 C:My Documentsfirst.cpp
    : `cout' not declared
    :
    : 4 C:My Documentsfirst.cpp
    : `main' must return `int'
    :
    : C:My Documentsfirst.cpp
    : [Warning] In function `int main(...)':
    :
    : 5 C:My Documentsfirst.cpp
    : `cout' undeclared (first use this function)
    :
    :
    : [Build Error] (Each undeclared identifier is reported only once
    :
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Your problems are as follows:

    1. Your compiler cannot find iostream.h
    You need to modify your compiler settings for include files to look in the directory where this file is stored, or better still use std::iostream (i.e without the h)

    2. std::cout is defined in , not

    3. Your compiler is enforcing the more modern style of main function which returns an int rather than void. Just put "return 0" at the end of your main function and you'll be OK. It should look something like

    [code]

    int main()
    {
    //code here
    return 0;
    }
    [/code]


    4. cout as "undeclared" goes back to point 1

    The basic problem is that you are trying to include old style header, but use new style std function calls. I'm not sure who told you to do that, but it's just plain wrong.

    Hope this helps


  • Your all giveing great advise but It still doesn't seem to work out for me, could some one post this program as it should be written and I'll past it to my compiler and see if I can get it to run?
  • : Your all giveing great advise but It still doesn't seem to work out
    : for me, could some one post this program as it should be written and
    : I'll past it to my compiler and see if I can get it to run?
    :

    just copy paste entire code, don't worry about anything after a // it won't affect your program

    #include
    using namespace std; //this needed to be changed
    int main()
    {
    cout<<"hello, how are you all?"<<endl; //a basic end line is added
    cin.get(); //waits for user to press enter before closing screen
    }

  • : just copy paste entire code, don't worry about anything after a //
    : it won't affect your program
    :
    : #include
    : using namespace std; //this needed to be changed
    : int main()
    : {
    : cout<<"hello, how are you all?"<<endl; //a basic end line is added
    : cin.get(); //waits for user to press enter before closing screen
    : }
    :

    This thread started [b]more then five years ago[/b].

    Please dont bring back dead topics.
  • :
    : : just copy paste entire code, don't worry about anything after a //
    : : it won't affect your program
    : :
    : : #include
    : : using namespace std; //this needed to be changed
    : : int main()
    : : {
    : : cout<<"hello, how are you all?"<<endl; //a basic end line is added
    : : cin.get(); //waits for user to press enter before closing screen
    : : }
    : :
    :
    : This thread started [b]more then five years ago[/b].
    :
    : Please dont bring back dead topics.


    I'm trying to get the webmaster to lock all old threads. We still don't know if they are brought back because of some technical problem or because of people who don't understand how to use the GUI. Anyway, I'm locking them as they pop up.
This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories