Dev-C++ menu

Shout-Out

User Tag List

Thread: Dev-C++

Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    ElfLite's Avatar Member
    Reputation
    2
    Join Date
    Mar 2008
    Posts
    35
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dev-C++

    After I compile and try to run a code, it'd usually run and then almost immediatly shut off on me. It shows for nearly a millisecond and just turns off by itself. Can't really find a setting that would make it stay longer or until chosen to close.

    Dev-C++
  2. #2
    Phygar's Avatar ( ͡° ͜ʖ ͡°)
    Reputation
    444
    Join Date
    Nov 2007
    Posts
    1,591
    Thanks G/R
    7/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try using cin

  3. #3
    ElfLite's Avatar Member
    Reputation
    2
    Join Date
    Mar 2008
    Posts
    35
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    // ask for a person's name, and greet the person
    #include <iostream>
    #include <string>
    int main()
    {
    // ask for the person's name
    std::cout << "Please enter your first name: ";
    // read the name
    std::string name; // define name
    std::cin >> name; // read into
    // write a greeting
    std::cout << "Hello, " << name << "!" << std::endl;
    return 0;
    }

    That's the code I tried this time and it turns as soon as the Hello "Name"! comes up on the screen, just have like a millisecond to see it.

  4. #4
    Phygar's Avatar ( ͡° ͜ʖ ͡°)
    Reputation
    444
    Join Date
    Nov 2007
    Posts
    1,591
    Thanks G/R
    7/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put a cin after the output.

  5. #5
    Xarg0's Avatar Member
    Reputation
    61
    Join Date
    Jan 2008
    Posts
    389
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    insert this at the end of main() previous return 0;
    Code:
    system("PAUSE");
    I hacked 127.0.0.1

  6. #6
    ElfLite's Avatar Member
    Reputation
    2
    Join Date
    Mar 2008
    Posts
    35
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Xarg0 View Post
    insert this at the end of main() previous return 0;
    Code:
    system("PAUSE");
    Yup it worked, thank you very much.

  7. #7
    SKU's Avatar Contributor
    Reputation
    306
    Join Date
    May 2007
    Posts
    565
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  8. #8
    TinusNED's Avatar Banned
    Reputation
    42
    Join Date
    Aug 2008
    Posts
    333
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may want to put this between the #include and int main()
    Code:
    using namespace std;
    Now you can leave std:: away

  9. #9
    ElfLite's Avatar Member
    Reputation
    2
    Join Date
    Mar 2008
    Posts
    35
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by SKU View Post
    I put that over return 0; and it just turned off immediatly again.

  10. #10
    TinusNED's Avatar Banned
    Reputation
    42
    Join Date
    Aug 2008
    Posts
    333
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:

    Code:
    // ask for a person's name, and greet the person
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    
    cout << "Please enter your first name: ";
    
    string name; // define name
    cin >> name; // read into
    
    cout << "Hello, " << name << "!" << endl;
    
    cin.ignore(cin.rdbuf()->in_avail() + 1);
    
    return 0;
    }

  11. #11
    Froogle's Avatar Legendary
    Reputation
    690
    Join Date
    Jan 2007
    Posts
    787
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    std::cin.get() isn't working because cin already has a value (from cin >> name; )

    See below...


    Code:
    // ask for a person's name, and greet the person
    #include <iostream>
    #include <string>
    int main()
    {
    // ask for the person's name
    std::cout << "Please enter your first name: ";
    // read the name
    std::string name; // define name
    std::cin >> name; // read into
    // write a greeting
    std::cout << "Hello, " << name << "!" << std::endl;
    //wipe buffer
    std::cin.clear();
    std::cin.sync();
    //get cin - prevent closing
    std::cin.get();
    return 0;
    }


  12. #12
    skatercam11's Avatar Member
    Reputation
    11
    Join Date
    Jun 2008
    Posts
    56
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here, this may be some better, and possible clearer example...

    Code:
    /* These are called libraries. They are used to gather a bunch of premade functions and use them for yourself */
    #include <iostream>
    #include <string>
    
    /* This uses the standard namespace (so you can excluse std::cout, and things of the like */
    using namespace std;
    
    int main()
    {
        /* This initalizes a string called "first_name" */
        string first_name;
        
        /* This outputs text onto the screen */
        cout << "Hello, please enter your first name: ";
        
        /* This reads the users input and puts the data into the string */
        cin >> first_name;
        
        /* Outputs text onto the screen and places the data for the first_name string onto the screen as well */
        cout << "Welcome, " << first_name << "!" << endl;
        
        /* Stops the window from automatically closing */
        cin.clear();
        cin.sync();
        cin.get();
        
        
        /* Returns a value of 1 if the program exited successfully */
        return 1;
    }
    Last edited by skatercam11; 05-31-2009 at 11:40 PM.

  13. #13
    noodles19's Avatar Member
    Reputation
    1
    Join Date
    Jan 2007
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or just scram the c function getchar(); before return 0 and you'll be fine

  14. #14
    Froogle's Avatar Legendary
    Reputation
    690
    Join Date
    Jan 2007
    Posts
    787
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *cough* getchar sometimes requires an extra include.

    And skatercam11, a link was previously posted in this thread as to why system("PAUSE") should not be used as it cannot be ported and it's a resource hog.


  15. #15
    LongBow's Avatar Member
    Reputation
    5
    Join Date
    Aug 2008
    Posts
    9
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Putting a while(1); before the return wouldn't require any includes and is platform independant.

Page 1 of 2 12 LastLast

Similar Threads

  1. [READ/RELEASE] One of the best EMU-Devs arround and some of his work posted here!
    By latruwski in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 11-17-2007, 07:43 AM
  2. Deathreach WoW Dev Team [recruiting]
    By Equ1N0X in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 11-02-2007, 06:40 PM
  3. [Help Wanted]Admin/Dev send Mail via Website
    By Zaphieon in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 10-19-2007, 11:48 AM
  4. Looking for MMORPG dev team.
    By shade599 in forum Community Chat
    Replies: 24
    Last Post: 08-15-2007, 07:11 AM
  5. Prog/Dev Island
    By dela in forum World of Warcraft General
    Replies: 3
    Last Post: 10-04-2006, 10:41 AM
All times are GMT -5. The time now is 06:43 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search