c - How compare number with numbers inside myfile -


i'm developing software , need insert students , check if same students registered in system.

int setnumaluno()       //definir num de aluno {     int num;     printf("\n");     printf("numero de aluno: \n");     scanf("%d", &num);     printf("a verificar se existe o aluno\n");     checkstudent(num);     return num;    }  void checkstudent(int num)//metodo responsavel por verrificar no ficheiro se o mesmo existe {     int numerofile=0;     int r = 0;      while (numerofile != eof)     {         numerofile = fscanf(fp, "%d", &r);         if (num == numerofile)             printf("numero existe");         else if (num != numerofile)             setnomealuno();      }  } 

i've tryed implement while cycle can't check if number exists in file. file called when fscanf() instruction can't check if have member number. how can perform, code, verify if student exists or not?

do way:

  1. use fopen open file , create file pointer.
  2. use fread read contents of file buffer.
  3. use strtol convert numbers in buffer long int; note there other functions other other type conversions.
  4. use fclose close file , free file pointer

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -