I try to edit a file in C but it does not work. The code creates the file if it does not exist but it can not edit it. I tried to change the file opening status but nothing. This is the code :
typedef struct{
    char name[MAXSTRING];
    int id;
  }student;
int main(int argc, const char **argv){
        i = 0;
        FILE *fp;
        if ( (fp=fopen("StudentsFile.dat", "w") ) == NULL ){
            printf("FILE CAN NOT OPEN");
        }else{
             printf("INSERT NAME AND ID OF THE STUDENT\n");
            student *stArray = (student *) malloc(sizeof(student));
            scanf("%s" "%d", &stArray->name, &stArray->id);
            while (!feof(stdin))
            {
                fprintf( fp ,"%s", stArray->name );
                scanf("%s" "%d", &stArray->name, &stArray->id);
                printf("%s ", &stArray->name);
            }
            fclose (fp);
         }
             return 0;
     }
 
    