Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
fgets() が実行された後、 buf の左側の部分がどうなるか知りたいです。例: 1 行が 10 文字 + '\n' だけの場合、buf の左側 (but[12] から buf[99] まで) には何が入るでしょうか? fgets() を 2 回実行すると、2 番目の入力は buf への最初の入力をカバーしますか? char buf[100]; fgets(buf, sizeof(buf), fp);
char buf[100]; fgets(buf, sizeof(buf), fp);
データを読み取るときfgets、制限に達するか、入力にターミネータが見つかるまで、バッファの要素を一度に 1 つずつ変更します (仮定を単純化します)。バッファー内の他のすべての要素は、呼び出し前と同じままですfgets(したがって、ランダムなデータが含まれているか、以前に読み取った情報が漏洩する可能性があります)。
fgets