Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>
- #include <string>
- using namespace std;
- string Readpart(HANDLE h)
- {
- char szSymbol;
- char szBuffer[128];
- int i = 0;
- bool flag;
- DWORD dwCount;
- do
- {
- flag = ReadFile(h, &szSymbol, 1, &dwCount, 0);
- szBuffer[i] = szSymbol;
- i++;
- } while (szSymbol != ' ' && flag);
- szBuffer[i] = '\0';
- //char* result = new char[strlen(szBuffer)];
- //strcpy(result, szBuffer);
- return string(szBuffer);
- }
- void main()
- {
- setlocale(LC_ALL, "rus");
- string buff_1, buff_2;
- LPCTSTR filename = TEXT("test_1.txt");
- HANDLE h = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
- if (h != INVALID_HANDLE_VALUE)
- {
- while (h != '\0')
- {
- SetFilePointer(h, 0, 0, FILE_CURRENT);
- buff_1 = Readpart(h);
- buff_2 = Readpart(h);
- cout << buff_2 << " " << buff_1;
- }
- }
- CloseHandle(h);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement