Advertisement
Guest User

Untitled

a guest
Jul 30th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main () {
  5.  
  6. FILE *test;
  7. char tekst[100];
  8. printf("%s","Podaj swoj string (nie uzywaj spacji)\n",tekst[100]);
  9. scanf("%s", &tekst);
  10. if ((test=fopen("test.txt", "w"))==NULL) {
  11. printf("%s","Nie mogę otworzyć pliku test.txt do zapisu!\n");
  12. return 0;
  13. }
  14. fprintf(test, "%s", tekst);
  15. fclose(test);
  16. char x;
  17. printf("%s","Chcesz wczytac zawartosc pliku(t/n)\n");
  18. scanf("\n%c",&x);
  19. if (x=='n')
  20. {
  21. printf("%s","ok");
  22. return 0;
  23. }
  24. if (x=='t')
  25. printf("%s","wczytuje zawartosc pliku..\n");
  26. if((test=fopen("test.txt", "r"))== NULL) {
  27. printf ("Nie moge otworzyc pliku test.txt do odczytu!\n");
  28. return 0;
  29. }
  30. fscanf (test, "%s", tekst);
  31. fclose (test);
  32. //printf("%s\n", tekst);
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement