Search This Blog

Tuesday, April 20, 2010

C programing fopen

Programmer Question

 #include <stdio.h>
#include <stdlib.h>
typedef struct aluno{
char cabecalho[60];
char info[100];
int n_alunos;
char dados[100];
char curso[100];
int numero;
char nome[100];
char e_mail[100];
int n_disciplinas;
int nota;
}ALUNO;

void cabclh(ALUNO alunos[],int a){
FILE *fp;
int i;
for(i=0;i<100;i++){
fp=fopen("trabalho.txt","r");

if(fp==NULL){
printf("Erro ao abrir o ficheiro\n");
}
while(!feof(fp)){
fgets(alunos[i].cabecalho,60,fp);
printf("%s\n",alunos[i].cabecalho);
}
}
fclose(fp);
}


what is wrong here?



main:



int main(int argc, char *argv[]){    
ALUNO alunos[100];
int aluno;
int b;

cabclh(aluno,b);

system("PAUSE");
return 0


Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails