Thread: Help Please !!!!!!!!

  1. #16
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by xxghostsxx
    Code:
    struct database
    {
      int id_number;
      int age;
      float salary;
    };
    
    int main()
    {
      database employee;  //There is now an employee variable that has modifiable 
    			    //variables inside it.
      employee.age=22;
      employee.id_number=1;
      employee.salary=12000.21;    
      return 0;
    }
    I need help again its show up and disappearing right away.
    I tried using system("pause");AND ther other one. but its given me an error. "SYSTEM" UNDECLARED

    HELP
    Put this at the beginning of your program:

    Code:
    #include <iostream>
    using namspace std;
    Including iostream allows you to use cin and cout (input and output). The 'using namespace std' part is the block of code named std that cin and cout are located, but dont worry about that yet.

    Then at the point you want it to pause (usually at the end of the program) put:

    Code:
    cin.ignore();
    cin.get();
    This leaves you with:

    Code:
    #include <iostream>
    using namspace std;
    
    struct database
    {
      int id_number;
      int age;
      float salary;
    };
    
    int main()
    {
      database employee;  /* There is now an object of the 'database' that allows you to edit the 
    variables inside of it, named employee. Object meaning a copy of it. */
    
      employee.age=22;
      employee.id_number=1;
      employee.salary=12000.21;    
    
      cin.ignore();
      cin.get();
    
      return 0;
    }
    Place those two together wherever you want to pause, I would forget about SYSTEM pause, but if you prefer to use it while learning its cool.
    Warning: Have doubt in anything I post.

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

  2. #17
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Oh by the way you seem to be going a little fast.. you might want to re-read the tutorials, take the quiz, and maybe try a few other site tutorials in order to get all the concepts. Tutorials are nothing compared to the depth and clarity taught in the books, so if youre only following a tutorial you may have to work harder and search around.
    Warning: Have doubt in anything I post.

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

  3. #18
    For Narnia! Sentral's Avatar
    Join Date
    May 2005
    Location
    Narnia
    Posts
    719
    Yours seem to work thanks
    and i also made a Division version of that one .
    ^ i know its not that impressing but hey i started reading that tutorial today i didnt Know nothing about c++ before and i am only 15 years old and i am trying to absorb everything that is tought in that tutorial . THANKS again for all your help.
    I am only 15 too. I've been going off the tutorials on this site for a little while, but got bored of them. So I switched to reading books, it's a lot more reliable, and informative. I am using C++ for dummies. It is quite good, but seems like it requires you to know a little C++ already. I just posted that code since it was the easiest to use and works with most of the mathmatical operations. Yours was a little too confusing, and didn't make much sense. I usually do things the easy way, but people end up making fun of my code.
    Videogame Memories!
    A site dedicated to keeping videogame memories alive!

    http://www.videogamememories.com/
    Share your experiences with us now!

    "We will game forever!"

  4. #19
    For Narnia! Sentral's Avatar
    Join Date
    May 2005
    Location
    Narnia
    Posts
    719
    Just don't keep going off of other peoples examples, too much. In programming there is no set way of doing things, which makes it so fun. I made the mistake of basing my programs off of other peoples programs, and it started to become boring for awhile. Just remember, there is more than one way to make a program. If it doesn't work, just keep changing, and compiling, works for me
    Videogame Memories!
    A site dedicated to keeping videogame memories alive!

    http://www.videogamememories.com/
    Share your experiences with us now!

    "We will game forever!"

  5. #20
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    like others have said, forget about system. try to avoid it like the plague. if you need a pause at the end of your program, just use this:
    Code:
    int main()
    {
        ...
        std::cin.get();
        return 0;
    }
    no need to use std::cin.ignore(1); there because you don't need the stream anymore, so there's no use in keeping it clean.

    the reason your compiler is complaining about system() is because it's in <cstdlib>, so you'd need to include that too.
    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

Popular pages Recent additions subscribe to a feed