Thread: What Now!!?

  1. #1
    human jerkey dead_captain's Avatar
    Join Date
    Jan 2008
    Location
    509
    Posts
    37

    What Now!!?

    Code:
    #include <iostream>
    using std::cout;
    using std::end1;
    
    int main()
    
    {
        cout << "hello mike!" << end1;
        cout << "press enter key to exit!!" << end1;
        std::cin.ignore(std::cin.rdbuf()->in_avail()+1);
        return 0;
    
    }
    Well it compiles. Now the window will not stay open. It just opens and closes. I thought this was right.

    What is going wrong?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Nothing is "going wrong", except there's nothing in your code to prevent the window from closing - it's doing exactly what you've asked for.

    There is an FAQ question "How do I prevent my window from closing", which you can probably look up and find the answer there.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    58
    1) say thanks on your previous post for sorting out your compiler!!

    2) Read the dev-c++ site

    3) get to the system pause part

    4)

    #include <cstdlib>
    #include <stdio.h>

    using namespace std;

    int main(int argc, char *argv[])
    {
    system("PAUSE");
    return EXIT_SUCCESS;
    }

  4. #4
    human jerkey dead_captain's Avatar
    Join Date
    Jan 2008
    Location
    509
    Posts
    37
    I believe I said thanks for the help.

    Thanks again, if not before.

    "can't we all just get along." LOL

  5. #5
    human jerkey dead_captain's Avatar
    Join Date
    Jan 2008
    Location
    509
    Posts
    37
    Code:
    #include <iostream>
    using namespace std;
    
    
    int main (int argc, char *argv[])
    
    {
        cout << "hello mike!" << end1;
        cout << "press enter key to exit!!" << end1;
        std::cin.ignore(std::cin.rdbuf()->in_avail()+1);
        system("PAUSE");
        return 0;
    
    }
    So, I still don't know what is wrong. system pause don't seem to work either. I am getting these compile errors.

    8 C:\Dev-Cpp\My code\test.cpp
    (Each undeclared identifier is reported only
    8 C:\Dev-Cpp\My code\test.cpp
    `end1' undeclared (fi C:\Dev-Cpp\My code\test.cpp
    [Warning] In function `int main(int, char**)':
    rst use this function)

    It still runs though.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485
    Try this:

    Code:
    #include <iostream>
    using namespace std;
    
    int main ()
    {
        cout << "hello mike!" << endl;
        cout << "press enter key to exit!!" << endl;
        system("PAUSE");
        return 0;
    }

  7. #7
    human jerkey dead_captain's Avatar
    Join Date
    Jan 2008
    Location
    509
    Posts
    37
    It still just pops up and closes right away. It is also saying the end1 is undeclared.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by dead_captain View Post
    Code:
    #include <iostream>
    using namespace std;
    
    
    int main (int argc, char *argv[])
    
    {
        cout << "hello mike!" << end1;
        cout << "press enter key to exit!!" << end1;
        std::cin.ignore(std::cin.rdbuf()->in_avail()+1);
        system("PAUSE");
        return 0;
    
    }
    So, I still don't know what is wrong. system pause don't seem to work either. I am getting these compile errors.

    8 C:\Dev-Cpp\My code\test.cpp
    (Each undeclared identifier is reported only
    8 C:\Dev-Cpp\My code\test.cpp
    `end1' undeclared (fi C:\Dev-Cpp\My code\test.cpp
    [Warning] In function `int main(int, char**)':
    rst use this function)

    It still runs though.
    Line 8 is the first cout line - look at the end of the line, and check for "similar characters", in this case a 1 and an l looking similar.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    human jerkey dead_captain's Avatar
    Join Date
    Jan 2008
    Location
    509
    Posts
    37
    well thanks for the advice, although still no luck.
    I have a book and it says this "should" work..

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by dead_captain View Post
    well thanks for the advice, although still no luck.
    I have a book and it says this "should" work..
    Describe "doesn't work" - what doesn't work? - and post the current code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    Nov 2006
    Posts
    58
    Hi,

    Another long shot, create a c project and just print hello world using <iostream>. The c++ project wont work on my pc either. Just give a try.

  12. #12
    human jerkey dead_captain's Avatar
    Join Date
    Jan 2008
    Location
    509
    Posts
    37
    Quote Originally Posted by tuurb046 View Post
    Hi,

    Another long shot, create a c project and just print hello world using <iostream>. The c++ project wont work on my pc either. Just give a try.
    Ok, well I don't know any C. I know it was before C++ but thats about it. Sorry for the dumb. lol
    thanks for trying though.

  13. #13
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by dead_captain View Post
    It still just pops up and closes right away. It is also saying the end1 is undeclared.
    end1 is not the right name - it is endl with a "L" at the end. Unfortunately some fonts don't show much difference between the number 1 and the letter L.

    Until you fix that, running your application won't reflect any other changes you make - it won't produce a valid executable with that error - so if you actually get something to "run", it will be your OLD executable from before you made some changes.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #14
    Registered User
    Join Date
    Nov 2006
    Posts
    58
    Hi,

    Just create your c project as you did your c++ project, and add your .cpp text file to the c project. And then use the same example as they provided above.

    Once you can print hello world, and confirm the compiler works, then you can move onto the next step of writing more programs.

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by tuurb046 View Post
    Hi,

    Just create your c project as you did your c++ project, and add your .cpp text file to the c project. And then use the same example as they provided above.

    Once you can print hello world, and confirm the compiler works, then you can move onto the next step of writing more programs.
    I'm 90% sure this is not really the problem - it may accidentally fix it, if Dead Captain fixes the typos in the current code when retyping the new code [which are also in the first post, so probably been there for some time].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed