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.
日付と時刻を追加した場所で次のことを試しましたが、ファイルには何も書き込まれません。??
QString hoho = QDate::currentDate().toString("yyyy.MM.dd") + QTime::currentTime().toString(".hh.mm.ss.zzz"); fprintf(fp, "%s timer timer3 timer5 timer6 timer7\n", hoho.toStdString().c_str());
FILE* は通常、完全にバッファリングされます。つまり、FILE* の内部バッファがいっぱいになるまで、または FILE* をフラッシュするまで、ファイルには何も書き込まれません (フラッシュは、ファイルを閉じるときにも行われます)。
したがって、 fprintf() 呼び出しの後にこれを追加してフラッシュします。
fflush(fp);