+ 2
What is wrong in this programming?
#include <stdio.h> int main() { int id,sa; char na; FILE *fp; fp=fopen("file.text","w"); printf("enter staff name,salary and id"); scanf("%s%d%d",na&sa&id); fprintf(fp,"%s\t%d\t%d\n,na,sa,id"); fclose(fp); return 0; }
2 Answers
+ 3
Your scanf line doesn't have commas between variables.
Your fprintf line seems to have the variables inside the quotation marks.
Your fclose line has (fopen("file.text","w")) as it's argument, is that correct?
Does C behave like Python when opening files? Should you use something like while/try when opening files?
+ 4
What are the expected and actual results?