想定
タイトル
サブタイトル
結果
END
END
という風に表示されました
何がいけなかったのでしょうか?
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#define MAX 2048
int main(void) {
FILE *fp;
char buf[500];// [MAX];
char *title, *subtitle;
if ((fp = fopen("test.txt", "r")) != NULL) {
while (fgets(buf, MAX, fp) != NULL) {
if (strstr(buf,"#END") != NULL) break;//STARTでヘッダ終了
if ((strstr(buf, "TITLE:") != NULL) && (strstr(buf, "SUBTITLE:") == NULL)) {//タイトル
title = strcpy(buf + 1, buf + 6);
continue;
}
if ((strstr(buf, "SUBTITLE:") != NULL)) {
subtitle = strcpy(buf + 1, buf + 9);
continue;
}
}
}
printf("%s", title);
printf("%s", subtitle);
while(1){}
return 0;
}