// C10_2.cpp : Defines the entry point for the console application. // 寫入文字到檔案 #include "stdafx.h" #include #include int main(int argc, char* argv[]) { ofstream File1; char Data[100]= "Happy NewYear" ; char strg[100]= "Merry Christmas" ; File1.open("File1.txt"); for(int i=0 ; i < 50 ; i++) { File1 << Data[i]; } File1 << endl; cout << "寫入 Data 值完成 !" << endl; for(int j=0 ; j < 50 ; j++) { File1 << strg[j]; } cout << "寫入 strg 值完成 !" << endl; return 0; }