#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
int main() {
unsigned int before[8000] = {0};
unsigned int after[2000] = {0};
unsigned int tmp = { 0 };
int i;
int count = 0;
char buffer[256] = { 0x00, };
int len;
FILE* fp = NULL;
FILE* fp2 = NULL;
fp = fopen("C:\\Users\\charlie Park\\Downloads\\random_sort.txt", "r");
assert(fp != NULL);
while (!feof(fp)) {
fgets(buffer, sizeof(buffer), fp);
//printf("%s", buffer);
if (buffer[0] != '\n') {
for (i = 0; i < 8; i++) {
if ('0' <= buffer[i] && buffer[i] <= '9')
buffer[i] -= '0';
else if ('A' <= buffer[i] && buffer[i] <= 'F')
buffer[i] = buffer[i] - 'A' + 10;
}
before[count] = buffer[0];
for (i = 0; i < 7; i++) {
tmp = buffer[i + 1];
before[count] = before[count] << 4;
before[count] = (before[count] | tmp);
}
count++;
}
}
fclose(fp);
len = strlen(before);
before[len] = NULL;
for(i=0;i<count;i++)
printf("%X \n", before[i]);
return 0;
}
'Programming$' 카테고리의 다른 글
string은 포인터가 아니라 레퍼런스로... (0) | 2017.11.03 |
---|---|
[c++] 컴파일하기 (0) | 2017.11.03 |
[c++] find 함수 (0) | 2017.11.03 |
[C++] Reference, 포인터 (0) | 2017.10.12 |
[C++] getline 함수 (0) | 2017.10.12 |