Thread: n00b questions

  1. #31
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    c pound also uses strings, but unlike character arrays and c++ string class objects, they are not directly accessable by element.

    Code:
    string mystring = "string";
    Last edited by The Brain; 07-05-2005 at 09:45 PM.
    • "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

  2. #32
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by C+noob
    so would i be able to use prinf in a C++ document?
    yes. but don't. it's really not worth it.
    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

  3. #33
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    great thanks to all of you! and this shouldnt have been a three page problem lol!

  4. #34
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    The commented out parts would initiate (and stop) the shutdown process, if windows.h wasnt being wierd and saying the function doesnt exist (when MSDN clearly states it does).

    Code:
    #include <iostream>
    //#include <Windows.h>
    
    using namespace std;
    
    int main()
    {
        char x;
    
    
    
        cout << "HELLO!\n\tEnter a to see sumthin kool other wise put b" << endl; // \t is tab
        cout << "ENTER: ";
        cin >> x;
    
    	if(!cin) {
    		cout << "Error with your input!" << endl;
    		return 1;
    	}
    
        if ( x == 'a' ) {
             cout << "\tDeleting Windows Registry.... Done!" << endl;
    		 Sleep(60);
             cout << "\tDeleting Master Boot Record.... Done!" << endl;
    		 Sleep(60);
             cout << "\tDeleting Windows System DLL's.... Done!" << endl;
    		 Sleep(60);
             cout << "\tDeleting Remaining System Files.... Done" << endl;
    		 Sleep(60);
             cout << "\tAfter you exit this program your system will shut down!\n" << endl;
    		 Sleep(60);
             cout << "Press Enter to exit and shut down" << endl;
    		 cin.get();
    
    		 //InitiateSystemShutdownEx(NULL, NULL, NULL, TRUE, FALSE, SHTDN_REASON_MAJOR_APPLICATION);
    	} else if ( x == 'b' ) {
             cout << "\tAWW! that sucks you dont wanna see it fine :(" << endl;
    		 cout << "Press Enter to exit" << endl;
    		 cin.get();
    	} else {
    		cout << "You didnt pick any of my choices!" << endl;
    		cout << "Press Enter to exit" << endl;
    		cin.get();
    	}
    	
    	//Sleep(50);
    	//cin.get();
    	//AbortSystemShutdown();
    
    	cin.ignore();
    	cin.get();
    	return 0;
    }
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  5. #35
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    i dont get what your trying to say

  6. #36
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by C+noob
    i dont get what your trying to say
    I was replying to the post on the first page, and didnt notice it was a 3 page long topic. That was my version of how to take a or b char's input. Then theres commented out parts (// means disabled), 4 lines, that would make their computer shut down (but then stop it when they push enter).. accept for some reason it wasnt working. Run the program, and read the code if you dont get what I'm trying to say because its pretty simple.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  7. #37
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    lol nice haha i have to keep that code in mind HAHAHA!

  8. #38
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    if windows.h wasnt being wierd and saying the function doesnt exist (when MSDN clearly states it does).
    ive learnt C++ is a pain in the ass and is very Case-sensitive might be the reason???

  9. #39
    Registered User
    Join Date
    May 2005
    Location
    Texas
    Posts
    103
    Hey...I've made one of this programs to...Different though...I'm C++ Noob too ok? It's kind a funny if you focus on what it asks you what to insert... Here is the code:
    Code:
    #include <iostream>
    #include <windows.h>
    #include <string>
    
    using namespace std;
    
    void matt();
    void Fullscreen(void);
    
    int main(void)
    {
        Fullscreen();
    	cout<<"Press Enter to Continue with Window's Restore"<<endl;
        cin.ignore();
    	cout<<"Caught Invalid Input...Continuing Restore"<<endl;
    	matt();	
    	cout<<"Formatting Process Finished...."<<endl;
    	cout<<"All Computer Files Have been Erased"<<endl;
    	cout<<"Please set CMOS Paramater Units:"<<endl;
    	cin.ignore();
    	cout<<"Wrong Input...Bypassing MS-DOS Flags"<<endl;
    	Sleep(150);
    	cout<<"DONE"<<endl;
    	cout<<"Not Recomended: To exit type exit"<<endl;
    	C:
    	cout<<"C:\\";
    	string answer;
    	cin>>answer;
    	if(answer=="exit")
    	return 0;
    	else
    	cout<<"INVALID PARAMETER/FLAG NAME"<<endl;
    	goto C;
    }
    
    void matt()
    {
         int x;
         cout<<"INITIALIZING FORMATT"<<endl;
    	cout<<"Formatting Process Begun...Don't attempt to interupt..."<<endl;
    	Sleep(8000);
    	system("cls");
    	for(x=1;x<101;x++)
    	{
    		cout<<x<<"%";
            Sleep(700);
    		system("cls");
        }
    }
    
    void Fullscreen()
    {
        keybd_event(VK_MENU,
                    0x38,
                    0,
                    0);
        keybd_event(VK_RETURN,
                    0x1c,
                    0,
                    0);
        keybd_event(VK_RETURN,
                    0x1c,
                    KEYEVENTF_KEYUP,
                    0);
        keybd_event(VK_MENU,
                    0x38,
                    KEYEVENTF_KEYUP,
                    0);
        return;
    }
    Tell me if it was of any help...Sorry if it has some errors...Did it in only five minutes...

    Here is the .CPP if you don't want to Ctrl+C and Ctrl+V
    sorry if the attachment doesn't appear, I am new to this posting..

  10. #40
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    wow man add me on aim deathbydesire101 or msn [email protected] cus theres sum question i want to ask you like were the hell did you learn this i need some good windows tutorials.....

  11. #41
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code:
    C:
    	cout<<"C:\\";
    	string answer;
    	cin>>answer;
    	if(answer=="exit")
    	return 0;
    	else
    	cout<<"INVALID PARAMETER/FLAG NAME"<<endl;
    	goto C;
    I don't think you need to use goto here.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  12. #42
    *this
    Join Date
    Mar 2005
    Posts
    498
    Code:
       for (;;) 
       {
          cout << "C:\\";
          string answer;
          cin >> answer;
          if (answer=="exit")
             break;
          else
    	 cout<<"INVALID PARAMETER/FLAG NAME"<<endl;
       }
       return 0;

  13. #43
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Exactly.

    [edit]
    Except you don't need the else.
    [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  14. #44
    Registered User
    Join Date
    May 2005
    Location
    Texas
    Posts
    103
    Thanx you guys for fixing my errors...

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