在.h中声明
CString words[MAX_NUM];
void CHistogramDlg::ReadFile(CString filePath)
{
FILE* f = fopen(filePath, "rt");
char buf[1024];
for (;;)
{
if (!fgets(buf, sizeof(buf) - 3, f))
break;
size_t len = strlen(buf);
while (len > 0 && isspace(buf[--len]));
buf[len + 1] = '\0';
}
CString recvBuffer = buf;;
char* charpoint;
charpoint = recvBuffer.GetBuffer(recvBuffer.GetLength());
const char* split = "\t";
char* p;
p = strtok(charpoint, split);
int i = 0;
while (p != NULL)
{
words[i++] = p;
p = strtok(NULL, split);
}
delete[] p;
fclose(f);
}