Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #if wersja==5
  2. using namespace std;
  3. int main()
  4. {
  5. int k = 0;
  6. char * wsk;
  7. char c[30];
  8. cout << "Podaj ciag szukany" << endl;
  9. cin.get(c, 30);
  10. char *a;
  11. a = &c[0];
  12. cout << c << endl;
  13. FILE *plik = nullptr;
  14. int dane;
  15. char znak;
  16. char buffer;
  17. if ((plik = fopen("test.txt", "r+")) != nullptr)
  18. {
  19.  
  20. while (!feof(plik))
  21.  
  22. {
  23. fscanf(plik, "%c ", &buffer);
  24. //cout << buffer;
  25. wsk = strchr(&buffer, *a);
  26. while (wsk != NULL)
  27. {
  28. wsk = strchr(wsk + 1, *a);
  29. k++;
  30.  
  31. }
  32.  
  33. }
  34. if (k>0)
  35. cout << "Liczba powtorzen w pliku: " << k;
  36. fclose(plik);
  37. }
  38. else
  39. cout << "Nie udalo sie otworzyc pliku na dysku!\n";
  40. cout << endl;
  41. return 0;
  42. }
  43. #endif//(wersja==5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement