new with structs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • svlsr2000
    Recognized Expert New Member
    • Feb 2007
    • 181

    #16
    One thing to rember, when you declare a structure, you should think it as a new data type.
    Struct SomeStruct{
    int data1;
    int data2
    };

    Now SomeStruct is a data type, just like int or float.

    You dont do something like float a;
    float = 10;

    You need to modify the variables, not the data type.

    Similarly in your code you need to modify your variable(mystat s) and not the datatype(basket ball)

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #17
      Originally posted by Ganon11
      Make sure you allocate some memory for that struct, or you'll get a whole bunch of segmentation faults:
      No need to worry; you can only get one segmentation fault per run ;-)

      kind regards,

      Jos

      Comment

      Working...