C - Call a function

Posted by Pedro on Stack Overflow See other posts from Stack Overflow or by Pedro
Published on 2010-05-08T00:04:31Z Indexed on 2010/05/08 0:08 UTC
Read the original article Hit count: 172

Filed under:
|

Hello. I want to get a value from a function in other function i think i have to call a function in other function, then call it on main, but how?

void funcA(PEOPLE people[], int *total){
FILE *fp;
char line[100];
fp=fopen("example.txt","r");
if(fp==NULL){
exit(1);
}

else{
fgets(line, 100, fp);//get a number from the txt
total=atoi(linha);//convert to int
}
}

void funcB(PEOPLE people[], int *total){
int i;
for(i=0;i<total;i++){
                    printf("%s\n",people[i].name);
}
funcA(people,&total);
}

void main(){
PERSON person[100];
int *total;
funcB(people,&total);


}

What i'm doing wrong?

© Stack Overflow or respective owner

Related posts about c

    Related posts about homework