stdin .ccファイルを使用して.txtファイルを読み取り、それをシェルに出力するにはどうすればよいですか?パート2 [重複]

stdin .ccファイルを使用して.txtファイルを読み取り、それをシェルに出力するにはどうすればよいですか?パート2 [重複]
//include file from a large library that gives us the ability to program in
//C++
#include <stdio.h>
#include <stdlib.h>

//
int main()
{
  File * fPointer;

  //fpointer gives direction to which file needs to be opened this case mytxt
  fPointer = fopen("mytext.txt","r");

  char singleLine[150];

  //feof = file end of file
  //means keep looping till end
  while(!feof(fPointer)) {

    //going to go line by line
    //
    fgets(singleLine, 150, fPointer);
   
  }

  //close the pointer or the use of this function
  fclose(fPointer);

  return(0);
}

どこかでプログラムを見てニーズに合わせて少し修正しました。私の目標は、プログラムを.exeに変換してmytext.txtファイルの内容を表示することです(5行の内容です)。数時間この問題を解決しようとしましたが、それでも問題が見つかりませんでした。助けてください。私はこれをうまくやっています。

[私はmobaxtermとunix linux shellを使用します(bashファイルだと思います)]

ありがとうございます。コロナ19時間健康です。

ベストアンサー1

おすすめ記事