Advertisement
Fruch

Untitled

May 10th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1.  
  2. #include <Windows.h>
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. string Readpart(HANDLE h)
  8. {
  9. char szSymbol;
  10. char szBuffer[128];
  11. int i = 0;
  12. bool flag;
  13. DWORD dwCount;
  14. do
  15. {
  16. flag = ReadFile(h, &szSymbol, 1, &dwCount, 0);
  17. szBuffer[i] = szSymbol;
  18. i++;
  19. } while (szSymbol != ' ' && flag);
  20. szBuffer[i] = '\0';
  21.  
  22. //char* result = new char[strlen(szBuffer)];
  23. //strcpy(result, szBuffer);
  24. return string(szBuffer);
  25. }
  26.  
  27. void main()
  28. {
  29. setlocale(LC_ALL, "rus");
  30. string buff_1, buff_2;
  31. LPCTSTR filename = TEXT("test_1.txt");
  32. HANDLE h = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  33. if (h != INVALID_HANDLE_VALUE)
  34. {
  35. while (h != '\0')
  36. {
  37. SetFilePointer(h, 0, 0, FILE_CURRENT);
  38. buff_1 = Readpart(h);
  39. buff_2 = Readpart(h);
  40. cout << buff_2 << " " << buff_1;
  41. }
  42. }
  43. CloseHandle(h);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement