I'm new to C so be patient please.
What are some legal ways to assign values to members with this kind of code?
struct bogus {
char *name;
int number;
float *extra;
};
typedef struct bogus FOO;
int main(void) {
FOO *sptr;
if (sptr = (FOO *)malloc(sizeof(FOO)) > 0) {
sptr->name = what works here?
sptr->number = what works here?
sptr->extra = what works here?
}
return 0;
}
I know this looks like HW , but it is just me trying to learn the language.
Thanks.
What are some legal ways to assign values to members with this kind of code?
struct bogus {
char *name;
int number;
float *extra;
};
typedef struct bogus FOO;
int main(void) {
FOO *sptr;
if (sptr = (FOO *)malloc(sizeof(FOO)) > 0) {
sptr->name = what works here?
sptr->number = what works here?
sptr->extra = what works here?
}
return 0;
}
I know this looks like HW , but it is just me trying to learn the language.
Thanks.