Thread: n00b questions

  1. #16
    Banned
    Join Date
    Jun 2005
    Posts
    594
    what are you putting in for your input?

  2. #17
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    a and it exits if i put a i want it to execute the if statemeent cus cin>> assigns the value of input to x wait a min if a = 10 then the input has to equal 10 one sec brb

  3. #18
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    wait now its working lol!!!! but i want the user to enter exe not a number

  4. #19
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Quote Originally Posted by MadCow257
    Something you really need to add is that once you press enter...it really shuts down.
    The function is this I think:
    Code:
    InitiateSystemShutdownEx(NULL, NULL, NULL, TRUE, FALSE, SHTDN_REASON_MAJOR_APPLICATION)
    http://msdn.microsoft.com/library/de...ason_codes.asp
    for more information
    to use that you will need to include Windows.h
    Why on earth would you really tell him how to shutdown the computer?
    Woop?

  5. #20
    Banned
    Join Date
    Jun 2005
    Posts
    594
    if you want the use to enter a character, then you need
    to define it as char instead of int, and in your if statments
    change it to x == 'a' and x == 'b' should get the trick done.

  6. #21
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    ooo ill try it!

  7. #22
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    i got the chars but how wouldi make it so the user will be able to nput it cus cin >> x can only be an int??????


    Code:
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    int main() 
    {
        int x;
        char execute;
        char dismiss;
        
        cout<<"HELLO!\n enter execute to see sumthin kool other wise put dismiss\n";
        cout<<" ENTER: ";
        cin>> x;
    	if(!cin)
    	{
    		cout << "Error with your input!" << endl;
    		return 1;
    	}
        cin.ignore();
        if ( x == 'execute' ) 
    	{
             cout << " Deleting Windows Registry.... Done!\n";
    		 Sleep(60);
             cout << " Deleting Master Boot Record.... Done!\n";
    		 Sleep(60);
             cout << " Deleting Windows System DLL's.... Done!\n";
    		 Sleep(60);
             cout << " Deleting Remaining System Files.... Done!\n";
    		 Sleep(60);
             cout << "After you exit this program your system will shut down!\n";
    		 Sleep(60);
             cout << "Press Enter to exit and shut down\n";
    		 cin.get();
    	}
             else if ( x == 'dismiss' ) 
    	{
             cout << " AWW! that sucks you dont wanna see it fine :(\n";
    		 cout << "Press Enter to Exit\n";
    		 cin.get();
    	}
    	else
    	{
    		cout << "You didnt pick any of my choices!" << endl;
    		cout << "Press Enter to Exit\n";
    		cin.get();
    	}
    	return 0;
    }

  8. #23
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by C+noob
    i got the chars but how wouldi make it so the user will be able to nput it cus cin >> x can only be an int??????
    well, cin can handle chars, strings, and just about anything you want it to (once you get more experienced). the problem is that you're declaring them as chars, but trying to assign strings... you might want to use the string class located in <string>


    Code:
    #include <iostream>
    #include <windows.h>
    #include <string>
    
    using namespace std;
    
    int main() 
    {
        string x;
        string e("execute");
        string d("dismiss");
        
        cout<<"HELLO!\n enter execute to see sumthin kool other wise put dismiss\n";
        cout<<" ENTER: ";
    
        getline(cin,x,'\n');
    
        if ( x == e) 
    	{
             cout << " Deleting Windows Registry.... Done!\n";
    		 Sleep(60);
             cout << " Deleting Master Boot Record.... Done!\n";
    		 Sleep(60);
             cout << " Deleting Windows System DLL's.... Done!\n";
    		 Sleep(60);
             cout << " Deleting Remaining System Files.... Done!\n";
    		 Sleep(60);
             cout << "After you exit this program your system will shut down!\n";
    		 Sleep(60);
             cout << "Press Enter to exit and shut down\n";
    		 cin.get();
    	}
             else if ( x == d) 
    	{
             cout << " AWW! that sucks you dont wanna see it fine :(\n";
    		 cout << "Press Enter to Exit\n";
    		 cin.get();
    	}
    	else
    	{
    		cout << "You didnt pick any of my choices!" << endl;
    		cout << "Press Enter to Exit\n";
    		cin.get();
    	}
    	return 0;
    }
    you may also want to look into making e and d constant (so they can't be changed) or compare x directly to the literal strings with if(x=="execute"){...}
    Last edited by major_small; 07-05-2005 at 09:16 PM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  9. #24
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    ok well is there a simple way and do i have to stick cin.ignore(); in there?

  10. #25
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by C+noob
    ok well is there a simple way and do i have to stick cin.ignore(); in there?
    nope. only with cin and cin.get() do you have to use cin.ignore(). the getline routine destroys the terminating character, which I set to be the newline that was tripping up your cin.get()'s later on in the program.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  11. #26
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    k thanks all of you i think this thread is long enough it works dont get the strings GOTTA READ more! *puts on nerd glasses* but noone ever did answer..... what is the diff between C/C#/C++??

  12. #27
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    C
    Code:
    printf("hello, world") ;

    C++
    Code:
    cout << "hello world" ;

    C#
    Code:
    System.Console.WriteLine("Hello world!") ;
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  13. #28
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    thank you everyone!!!!

    ~mod close plz

  14. #29
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    also:
    C++
    Code:
    string a;
    C
    Code:
    char a[int];
    C#
    Code:
    Brain help me out
    Quote Originally Posted by C+noob
    thank you everyone!!!!

    ~mod close plz
    generally around here threads don't get closed when they get answered... only if it's a racy topic or something, which belongs over at http://www.entropysink.com anyway [/shameless plug]
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  15. #30
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    lol sorry im used to forums were we have to ask after topic has been answered so generally the made C easier and C++ looks to be easiest i head also that printf() is faster than std::cout

    so would i be able to use prinf in a C++ document?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Couple of simple directdraw questions.
    By Deo in forum Game Programming
    Replies: 3
    Last Post: 05-25-2005, 07:55 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. Taking up OpenGL(extreme n00b questions)
    By Xterria in forum Game Programming
    Replies: 3
    Last Post: 03-26-2004, 04:49 PM