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.
で開いたファイルがありますfopen。同じファイルを(開いている間に)再度開く方法はありますが、別のシークがありますか?(したがって、freadを個別に使用できます)
fopen
読み続ければ問題ありません。
ファイルに書き込む場合、特にファイルへの読み取り/書き込みと同時にアクセスする2つのスレッドがある場合は注意してください。
コードがそのように見える場合
FILE *fp1, *fp2; fp1 = fopen("file", "r"); fp2 = fopen("file", "r");
次に、同じファイルに2つのシークがあります。シークの位置は独立しています。からの読み取りfp1は、fp2
fp1
fp2