1行と複数行の違い(・o・?)

abcde
記事: 0
登録日時: 14年前

1行と複数行の違い(・o・?)

投稿記事 by abcde » 14年前

VisualC++を使って作ってみた。
Cと.Netを混在させると面倒だとは思いつつも・・・

↓このコードで出力した dummy1.txt, dummy2.txt を下のコードを使って読み込む。

CODE:

             System::Diagnostics::ProcessStartInfo^ userProcess
               = gcnew System::Diagnostics::ProcessStartInfo;

             // nslookup
             userProcess->FileName = L"cmd.exe";
             userProcess->Arguments = 
               L"/C nslookup google.co.jp > dummy1.txt";
             System::Diagnostics::Process::Start(userProcess);

             // ping
             userProcess->FileName = L"cmd.exe";
             userProcess->Arguments = 
               L"/C ping google.co.jp > dummy2.txt";
             System::Diagnostics::Process::Start(userProcess);

CODE:

             char buf[256];
             FILE *fp;

             fp = fopen("dummy1.txt", "r");
             while(fgets(buf, 256, fp)) {
               this->textBox2->Text += 
                 System::Runtime::InteropServices::Marshal
                 ::PtrToStringAnsi(IntPtr(buf));
             }
             fclose(fp);

             fp = fopen("dummy2.txt", "r");
             while(fgets(buf, 256, fp)) {
               this->textBox2->Text += 
                 System::Runtime::InteropServices::Marshal
                 ::PtrToStringAnsi(IntPtr(buf));
             }
             fclose(fp);
すると、なぜか dummy1.txt (nslookupの結果) は1行で表示されて、dummy2.txt (pingの結果) は複数行で表示される。(ーヘー;)
最後に編集したユーザー abcde on 2011年3月20日(日) 09:38 [ 編集 2 回目 ]

コメントはまだありません。