Currently doing C programming homework, I want to update the value in the file. But now I'm having a problem updating it. The problem I faced now was the codes below update the values but in the form of new lines. Instead of replace the original lines. What's wrong with my codes ?
FILE* phoneFile;
int position_in_file,newStock;
printf("Enter new stock: ");
scanf("%d",&newStock);
position_in_file = ftell(phoneFile);
fseek(phoneFile,position_in_file,SEEK_SET);
fprintf(phoneFile,"%s %s %d %d %d\n",mobile[i].mCode,mobile[i].mName,
&mobile[i].mCost,&mobile[i].mPrice,newStock);