fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void) {
  5. // your code goes here
  6. char mytext[32];
  7. FILE *fp;
  8. fp = fopen("myfile.txt", "a+");
  9. if (fp == NULL) {printf("Error"); return 0;}
  10. fputs("30", fp);
  11. fputs("32", fp);
  12. fclose(fp);
  13. fp = fopen ("myfile", "r");
  14. if (fp == NULL) return 0;
  15. fgets(mytext, sizeof(mytext), fp);
  16. printf("mytext: %s-", mytext);
  17. fclose(fp);
  18. return 0;
  19. }
Success #stdin #stdout 0s 9416KB
stdin
Standard input is empty
stdout
Error