fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct lnode {
  5. char name[10];
  6. int points;
  7. int expense;
  8. int income;
  9. struct lnode *next;
  10. } ;
  11.  
  12. int main(void) {
  13.  
  14. lnode *head, *tail,*p;
  15.  
  16.  
  17.  
  18. head=NULL;
  19. tail=NULL;
  20. FILE *infile = fopen("c:/H7.txt", "r");
  21.  
  22. do
  23. {
  24. lnode *newptr=(lnode *)malloc(sizeof(lnode));
  25. newptr->next=NULL;
  26. if (head == NULL) {
  27. head = newptr;
  28. }
  29. else {
  30. tail->next=newptr;
  31. }
  32. tail = newptr;
  33.  
  34. fscanf(infile,"%s %d %d %d ", &tail->name,&tail->points,&tail->expense,&tail->income);
  35.  
  36.  
  37. }while(infile=);
  38.  
  39.  
  40. do
  41. {
  42. printf("%s %d %d %d\n",head->name,head->points,head->expense,head->income);
  43.  
  44. head = head->next;
  45. }while (head != NULL);
  46.  
  47. system("pause");
  48. return 0;
  49. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:34: warning: format ‘%s’ expects type ‘char*’, but argument 3 has type ‘char (*)[10]’
prog.cpp:37: error: expected primary-expression before ‘)’ token
prog.cpp:14: warning: unused variable ‘p’
prog.cpp:34: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:47: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
stdout
Standard output is empty