Thread: n00b questions

  1. #1
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178

    n00b questions

    how would you go about making headers?> i mean whats the point?

    and where would there be a good tutorial to make gui applications?

    and why would C++ be better than Visual Basic?

    last thing im makin a program to scare my friends usin the if statement why wont it work i started yesturday dont even know the diff between C/C#/C++

    HELP THE N00B! lol

  2. #2
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    *attacheches source code*

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() 
    {
        int x;
        int a;
        int b;
        
        cout<<"HELLO!\n enter a to see sumthin kool other wise put b\n";
        cout<<" ENTER: ";
        cin>> x;
        cin.ignore();
        if ( x == a ) {
             cout<<" Deleting Windows Registry.... Done!\n";
             cout<<" Deleting Master Boot Record.... Done!\n";
             cout<<" Deleting Windows System DLL's.... Done!\n";
             cout<<" Deleting Remaining System Files.... Done\n";
             cout<<"After you exit this program your system will shut down!\n";
             cout<<"Press Enter to exit and shut down\n";
    }
        
        else if ( x == b ) {
             cout<<" AWW! that sucks you dont wanna see it fine :(\n press enter to exit";
    }
    cin.get();
    }

  3. #3
    Banned
    Join Date
    Jun 2005
    Posts
    594
    >>how would you go about making headers?> i mean whats the point?

    Header usually just hold function for your program,
    it helps reduce the size of your main code to store
    function in header file.

    >>and where would there be a good tutorial to make gui applications?
    i say you should wait till you understand c++ better before
    attempting win32 programming.

    >>and why would C++ be better than Visual Basic?
    i would say c++ is a faster language then VB,
    and you can pretty much create anything you
    can think of with c++;

  4. #4
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    great now i just need to know what is wrong with my code

  5. #5
    Banned
    Join Date
    Jun 2005
    Posts
    594
    Code:
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    int main() 
    {
        int x;
        int a = 10;
        int b = 20;
        
        cout<<"HELLO!\n enter a to see sumthin kool other wise put b\n";
        cout<<" ENTER: ";
        cin>> x;
    	if(!cin)
    	{
    		cout << "Error with your input!" << endl;
    		return 1;
    	}
        cin.ignore();
        if ( x == a ) 
    	{
             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 == b ) 
    	{
             cout << " AWW! that sucks you dont wanna see it fine :(\n press enter to exit";
    		 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;
    }
    What you did was not set your variable equal to anything
    that you were testing them to in your if statments,

    and i added a few other things that might interest you,
    such as Sleep(), which is included in windows.h,
    which create a pause for the time you choose in milliseconds.

    oh and the !cin if statment check for bad input from the user.

  6. #6
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    whoa i mean im ok with preograqmmin cus IM AN UNBEATABLE 14 YEAR OLD PHP PROGRAMMER!@ lol but im guessing sleep() is amount of time between cout statements? another thing is i never did get the return 1 or return 0 thingy

  7. #7
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    the problem is it closes right after input i thoght cin.ignore() prevented this?

  8. #8
    Banned
    Join Date
    Jun 2005
    Posts
    594
    yea werid doesnt close for me, anyways
    you usually return 0, at the end of program to state a
    successful run, i always put put return #;
    in other part of my program where it possible to
    have some kind of error, that way if i get an error
    i know where to find it by using another program that catch
    what the program returns.

    anyways if you know funciton yet, it just like returning somethign
    from a funciton.

  9. #9
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    GRR! why does it close for me! it flashes error with your input quickly and closes!!!!!!!!1 im using the Dev-C++ compiler

  10. #10
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    More like cin.get();

  11. #11
    Banned
    Join Date
    Jun 2005
    Posts
    594
    oh yea, when you put in the wrong information
    it will close real fast, you cna fix that by putting
    a Sleep function there to, because
    cin.get() doesnt do anything in that case.


    if you run it thru a command prompt you wills ee it dispaly the error.

  12. #12
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    i dont get it it was made to run thru the command prompt and when i press enter it closes

  13. #13
    Banned
    Join Date
    Jun 2005
    Posts
    594
    double clicking the program, and running it in the command prompt
    are two different things.

    anyways what do you mean when you press enter it closes, it is
    suppose to do that.

    you enter your number, it run thru the if statment then
    run the valid target, then it wait for you to press enter
    once again and the program should terminate.

  14. #14
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    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

  15. #15
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    Quote Originally Posted by ILoveVectors
    double clicking the program, and running it in the command prompt
    are two different things.

    anyways what do you mean when you press enter it closes, it is
    suppose to do that.

    you enter your number, it run thru the if statment then
    run the valid target, then it wait for you to press enter
    once again and the program should terminate.
    when i put my input into it once i pres enter so input the input it closes dont even let me see the statement.

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