Thread: Help with Structures!

  1. #1
    Registered User
    Join Date
    Nov 2010

    Question Help with Structures!

    I am new to the world of structures and pointers, and was trying to use a modified version of the program example given in the structures tutorial. Every time I try to run it, it crashes. Any advice?

    #include <iostream>
    using namespace std;
    struct database
        int id_number;
        int age;
        float salary;
    int main()
        database employee;
        database *ptr,*ptr1,*ptr2;

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    You appear to have forgotten to initialise ptr, ptr1 and ptr2. You presumably want then to point to employee.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2010

    Talking oh!

    Oh! I see...stupid mistake on my part. Thank you very much for your help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with Nested Structures and Arrays of Structures
    By Ignoramus in forum C Programming
    Replies: 4
    Last Post: 03-02-2010, 01:24 AM
  2. Structures and dynamically allocated arrays
    By Bandizzle in forum C Programming
    Replies: 7
    Last Post: 10-04-2009, 02:05 PM
  3. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  4. Structures, and pointers to structures
    By iloveitaly in forum C Programming
    Replies: 4
    Last Post: 03-30-2005, 06:31 PM
  5. Methods for Sorting Structures by Element...
    By Sebastiani in forum C Programming
    Replies: 9
    Last Post: 09-14-2001, 12:59 PM

Tags for this Thread