N
noridotjabi
I have a program (its gigantic so I'm not posting the source) that I'm
writing with two probelms. First of all can someone give me an example
of how fgets is suposed to be used because I've read its man pages but
I still get a segmentation fault everytime I try to use it. Second
here is the problem with structures.
#include <stdio.h>
typedef struct MY_STRUCT{
int one;
int two;
}MSTCT;
void pins(MSTCT *st, int num) {
*st.one = num;
return; /* this is just a habit of mine */
}
int main() {
MSTCT *mystructure;
pins(mystructure.one, 1);
printf("In my strucure is %d\n", *mystruct.one);
return 0;
}
When I try to compile this I get something along the lines of trying to
acces a member outside of a structure or union. So I tried:
#include <stdio.h>
struct MY_STRUCT{
int one;
int two;
};
void pins(struct MY_STRUCT *st, int num) {
*st.one = num;
return; /* this is just a habit of mine */
}
int main() {
struct M_STRUCT *mystructure;
pins(mystructure.one, 1);
printf("In my strucure is %d\n", *mystructure.one);
return 0;
}
Unfortunately this did not work either. I am now curious as to what I
am doing wrong. Thanks in advanced.
Nori
writing with two probelms. First of all can someone give me an example
of how fgets is suposed to be used because I've read its man pages but
I still get a segmentation fault everytime I try to use it. Second
here is the problem with structures.
#include <stdio.h>
typedef struct MY_STRUCT{
int one;
int two;
}MSTCT;
void pins(MSTCT *st, int num) {
*st.one = num;
return; /* this is just a habit of mine */
}
int main() {
MSTCT *mystructure;
pins(mystructure.one, 1);
printf("In my strucure is %d\n", *mystruct.one);
return 0;
}
When I try to compile this I get something along the lines of trying to
acces a member outside of a structure or union. So I tried:
#include <stdio.h>
struct MY_STRUCT{
int one;
int two;
};
void pins(struct MY_STRUCT *st, int num) {
*st.one = num;
return; /* this is just a habit of mine */
}
int main() {
struct M_STRUCT *mystructure;
pins(mystructure.one, 1);
printf("In my strucure is %d\n", *mystructure.one);
return 0;
}
Unfortunately this did not work either. I am now curious as to what I
am doing wrong. Thanks in advanced.
Nori