C 程式設計時如何用進行檔案的輸入與輸出操作

時間 2022-04-25 23:07:43

1樓:匿名使用者

c++的流檔案處理

ifstream -- 從已有的檔案讀ofstream -- 向檔案寫內容fstream - 開啟檔案供讀寫

2樓:匿名使用者

c++和c讀取,寫檔案沒啥區別

#include

using namespace std;

void creat()//建立檔案並且輸入資訊fprintf(fp,"%-10s%-20s%-50s\n","姓名","**號碼","住址");

cout<<"請依次輸入姓名、**號碼、住址(以0結束)\n";

cin>>name;

while(strcmp(name,"0"))fclose(fp);

}void output()//輸出檔案的內容cout<<"\t通訊錄\n";

while(!feof(fp))

fclose(fp);

}int main()

{/*char a[20]="12";

int b= atoi(a);;//吧字串變成數字cout<

c程式設計提取檔名時如何去掉字尾,C 程式設計提取檔名時如何去掉字尾

string filepath c 1.txt string str 獲取檔案的全路徑 path.getfullpath filepath c 1.txt str 獲取檔案所在的目錄 path.getdirectoryname filepath c console.writeline str str...

c語言程式設計中如何清屏,C語言程式設計中如何清屏?

c語言並不提供這種功能。這與所使用的作業系統有關,需要看對應作業系統中的清屏命令是什麼,然後可以在c語言中進行系統呼叫。include stdlib.h system cls system cls 標頭檔案 stdlib.h include 下的 system cls 或者把游標設定到0,0實現偽清...

C語言程式設計時出現乙個錯誤,程式設計c語言總是有乙個錯誤

可以貼一出程式來嗎?你的 中是不是有賦值語句,看看它的左值是不是合法。這個程式是 書中的乙個例題 你可以照書中仔細看看 乙個求潤年的程式。你的程式執行起來沒問題。程式設計c語言總是有乙個錯誤 c語言程式設計總是乙個錯誤 15 沒看明白你程式的意思。但這裡應該是有問題的。for i 2 i k i i...

程式設計,c語言,c語言程式設計

這也值40分。好吧,等下啊我敲 密碼不用加防盜保護吧。寫好了,這應該是你要的 程式 include define imax 5000 define imin 50 define omax 1000 define 0min 50 long pw,money void in printf 超出範圍!失敗...

c語言程式設計,急,c語言程式設計?

include main if n 2 for n 1 n i n for k 1 k n k printf n 試試行不 int n int a 100 int b 100 a 0 1 scanf d n for int i 0 i n i for int j 0 j n i j printf f...