Thread: Im a begginer please help!

  1. #1
    Registered User zergdeath1's Avatar
    Join Date
    Sep 2003
    Posts
    39

    Im a begginer please help!

    When i compile this code the thing has no errors but it doesnt have any "size" either do u know whats wrong?

    Code:
    #include <iostream.h>
    
    int main()
    {
    int num, numtwo;
    cout<<"Hi, this is a test\n what is ur favorite #:";
    cin>>num;
    cout << "Enter anouther";
    cin>>numtwo;
    cout<< "u entered:" << num;
     cout<< "first then : "<< numtwo;
      cout<<"secound.";
    std::cin.get();
    return 0;
    }
    Stolen Quote: Buttered Toast always lands butter side down and cats always land on their feet, what happens when you strap buttered Toast to the back of a cat?
    My Quote: Practice Makes Perfect Nobodys Perfect Why Practice?

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787

    Re: Im a begginer please help!

    Originally posted by zergdeath1
    When i compile this code the thing has no errors but it doesnt have any "size" either do u know whats wrong?
    you need to stick with standards... try this...
    Code:
    #include <iostream>  //take out the .h
    using namespace std; //always put this in
    
    int main()
    {
         int num, numtwo;
         cout<<"Hi, this is a test\n what is ur favorite #:";
         cin>>num;
         cout << "Enter anouther";
         cin>>numtwo;
         cout<< "u entered:" << num;
           cout<< "first then : "<< numtwo;
           cout<<"secound.";
         cin.get(); //the std:: part was defined above (using namespace std)
         return 0;
    }
    i'm guessing you tried to learn the std::cin.get(); part on your own... that was right, but it was standards-compliant when the rest of your program wasn't...
    Last edited by major_small; 10-19-2003 at 10:06 AM.
    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. #3
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    I have no clue as to what you mean by "size". Do you mean the file size? Did you save the file?

    The code you wrote shouldn't have compiled, so I've changed it to make it work.
    Code:
    #include <iostream>
    
    using std::cout;
    using std::cin;
    
    int main()
    {
    	int num, numtwo;
    
    	cout<<"Hi, this is a test\n what is ur favorite #:";
    	cin>>num;
    	cout << "Enter anouther";
    	cin>>numtwo;
    	cout<< "u entered:" << num;
    	cout<< "first then : "<< numtwo;
    	cout<<"secound.";
    
    	cin.ignore();
    	cin.get();
    
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2 Begginer questions...
    By SoulBlade in forum C++ Programming
    Replies: 5
    Last Post: 01-18-2006, 05:04 PM
  2. Good C++ books for a begginer
    By Rare177 in forum C++ Programming
    Replies: 13
    Last Post: 06-22-2004, 04:30 PM
  3. begginer: having trouble with "if" command.
    By imortal in forum C Programming
    Replies: 2
    Last Post: 01-08-2003, 08:34 PM
  4. Help with begginer C++ program.
    By EZ15 in forum C++ Programming
    Replies: 2
    Last Post: 12-03-2002, 01:00 AM
  5. Making text adventures (begginer)
    By funkydude9 in forum C++ Programming
    Replies: 6
    Last Post: 03-08-2002, 03:28 AM