Я читаю файл под названием "dictionary.txt" с помощью fgets и распечатываю, но, как и 10% текста заголовка из "dictionary.txt", теряется при запуске программы.
Я подозреваю, что размер буфера небольшой, но изменение MAX_INT на большее число тоже не поможет.
#include <stdio.h>
#include<string.h>
#define MAX_INT 50000
void main() {
FILE *fp;
char* inp = (char*)malloc(sizeof(char)*MAX_INT);
int i;
int isKorean = 0;
char* buffer[MAX_INT];
char* ptr = (char*)malloc(sizeof(char)*MAX_INT);
if (fp = fopen("C://Users//user//Desktop//dictionary.txt", "r")) {
while (fgets(buffer, sizeof(buffer), fp)) {
ptr = strtok(buffer, "/"); //a line is looking like this : Umberto/영어("English" written in Korean)
for (i = 0; i < strlen(ptr); i++) {
if ((ptr[i] & 0x80) == 0x80) isKorean = 1; //check whether it's korean
if (!isKorean) printf("%c", ptr[i]); //if it's not korean, then print one byte
else {
printf("%c%c", ptr[i], ptr[i + 1]); //if it's korean, then print two bytes
i++;
}
isKorean = 0;
printf("\n");
}
ptr = strtok(NULL, " ");
printf("tagger:%s\n", ptr); //print the POS tagger of the word(it's in dictionary)
}
fclose(fp);
}
}