EDIT:
whats wrong with my structure?, i always do it like this, but i get errors this time
Code:#include <stdio.h> struct rec { int age,id=0; char name[31]; }; int main(){ char iuser[31]; int c=0; int input; }
EDIT:
whats wrong with my structure?, i always do it like this, but i get errors this time
Code:#include <stdio.h> struct rec { int age,id=0; char name[31]; }; int main(){ char iuser[31]; int c=0; int input; }
Last edited by rodrigorules; 09-20-2005 at 09:01 AM.
You can't initialize a variable inside a struct definition. I really doubt you always do it that way. Also, next time it would be nice if you actually included the error message you get including the line number.Code:int age,id=0;
Last edited by itsme86; 09-20-2005 at 09:19 AM.
If you understand what you're doing, you're not learning anything.
If you want to initialize a struture when you define it, you can do this:Originally Posted by rodrigorules
first two zeros are for, age and id. "string" is for, name.Code:struct rec { int age,id=0; char name[31]; } recVar = {0, 0, "string"};
OR...
During declaration:
Code:struct rec recVar = {0, 0, "string"};
ya thanks eddie, learned something new