fscanf を使用しようとするのではなく、';' を指定して "getdelim" を使用しないでください。区切り文字として。マニュアルページによると
" getdelim() は getline() と同様に機能しますが、改行以外の行区切り文字を delimiter 引数として指定できる点が異なります。getline() と同様に、ファイルの終わりの前に入力に区切り文字が存在しない場合、区切り文字は追加されません。到達しました。」
したがって、次のようなことができます(テストされておらず、コンパイルされていないコード)
char *line = NULL;
size_t n, read;
int alloc = 100;
int lc = 0;
char ** buff = calloc(alloc, sizeof(char *)); // since you don't know the file size have 100 buffer and realloc if you need more
FILE *fp = fopen("FILE TO BE READ ", "r");
int deli = (int)';';
while ((read = getline(&line, &n, fp)) != -1) {
printf("%s", line); // This should have "input A0;"
// you can use either sscanf or strtok here and get A0 out
char *out = null ;
sscanf(line, "input %s;", &out);
if (lc > alloc) {
alloc = alloc + 50;
buff = (char **) realloc(buff, sizeof(char *) * alloc);
}
buff[lc++] = out
}
int i = 0 ;
for (i = 0 ; i < lc; i++)
printf ("%s\n", buff[i]);