// C10_3.cpp : Defines the entry point for the console application. // 計數字串大小 #include "stdafx.h" #include #include #include int main(int argc, char* argv[]) { ofstream File1; int n1,n2; char Data[100]= "孤單芭蕾" ; char strg[100]= "芭蕾嘻哈舞曲" ; n1 = strlen(Data); cout << "Data 字元長度 : " << n1 << endl; n2 = strlen(strg); cout << "strg 字元長度 : " << n2 << endl; 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; }