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で呼び出されるため。テキスタイルに出力する前に、格納されている文字列の配列を変更したいと考えています。
例 元のファイル
Hello How Are you? good.
出力ファイル
1 Hello 2 How Are you? 3 4 good.
私がこのプログラムに求めた次のステップは、空白行を出力しないことです。しかし、私が尋ねた元の質問に関しては、これは魅力のように機能します。洞察@optimistをありがとう。
while( ( fgets( b, MAX, src ) ) != NULL ) { linecount++; fprintf( dst, "%d: ", linecount ); fputs( b, dst ); }