檔案輸入輸出c 程式,乙個 檔案輸入輸出 c 程式

2022-05-24 15:35:05 字數 706 閱讀 8170

1樓:c程式人生

你這段**比較老了,用標準的c++編譯器肯定過不了,因為跟現在的標準c++規範有很多不同,需要修改的地方很多。

下面是我給你修改好了的**:

#include

#include

#include

using namespace std;

int main()

程式說明:這段**會在程式所在的目錄下生成乙個my.dat的檔案,檔案內容是tsinghua

2401

name:

number:217088

2樓:匿名使用者

你的輸出讀寫到my.dat這個檔案裡去了,怎麼能在螢幕上看到東西呢。

這是my.dat檔案裡的內容:

tsinghua

2401

name:tsinghua

number:401

我猜和你想要的不一樣吧~

把infile>>name>>c>>number;

改為infile>>name>>number;

希望可以幫到你~

3樓:

ifstream infile;

ofstream outfile;

修改為:

ifstream *infile;

ofstream *outfile;

C語言輸入輸出重定向,C語言如何重定向輸入和輸出?

在c語言中,可以使用freopen將輸入輸出重定向。c語言的標準輸入輸出為stdin和stdout,這兩個變數的型別為file 型別,也就是說,標準輸入輸出操作,其本質還是檔案操作。當需要重定向時,可以呼叫。stdin freopen r stdin stdout freopen w stdout ...

C語言的輸入輸出,c語言是通過什麼來輸入輸出的?

char a a int b 20 printf d,d a b,b a a a a a 1 這個怎麼輸出,最好是有步驟的說,謝謝。輸出66,34 計算a 1 因為a a asicl碼值是65 此時a 66輸出 a b,b a 逗號表示式的返回值是最右邊的 而最右邊的是賦值式,它的值就是被賦值的結果...

C語言編寫程式,實現輸入n個整數,輸出其中最小的數,並指出其是第幾個數

include void main if min v value 後面的輸入與最小值比較,小則取代最小值 printf 第 d個數最小,為 d min p,min v include define max 1000 void swap int x int y int main printf 最小數為...