Created
October 23, 2016 00:34
-
-
Save koron/eafe5ba0d426ef52543464a64396a8a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
void readfile(HANDLE h, char *buf, int size) { | |
BOOL r; | |
DWORD nr; | |
int i; | |
r = ReadFile(h, buf, size, &nr, NULL); | |
printf("r=%d nr=%d", r, nr); | |
if (r != 0) { | |
printf(" :"); | |
for (i = 0; i < nr; ++i) { | |
printf(" %02x", (int)buf[i] & 0xff); | |
} | |
} | |
printf("\n"); | |
} | |
int | |
main(int argc, char* argv[]) { | |
HANDLE h = GetStdHandle(STD_INPUT_HANDLE); | |
char buf[7]; | |
readfile(h, buf, sizeof(buf)-1); | |
readfile(h, buf, sizeof(buf)-1); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\home\koron\tmp>type test.txt | |
aあいうえおかきくけこ | |
D:\home\koron\tmp>type test.txt | a | |
r=1 nr=6 : 61 82 a0 82 a2 82 | |
r=1 nr=6 : a4 82 a6 82 a8 82 | |
D:\home\koron\tmp>a | |
aあいうえおかきくけこ | |
r=1 nr=7 : 61 82 a0 82 a2 82 00 | |
r=1 nr=6 : 82 a9 82 ab 82 ad |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment