C++ File Processing〔fstream〕
来源:互联网 发布:湖南软件职业学院好吗? 编辑:程序博客网 时间:2024/05/17 02:27
C++ File Processing
Microsoft Visual C++ Version
#include <fstream>#include <iostream>#include <string>using namespace std;int main(){ char FileName[20];char EmployeeName[40], Address[50], City[20], State[32], ZIPCode[10];// 1. Uncomment the following section to create a new file/* cout << "Enter the Following pieces of information/n";cout << "Empl Name: "; cin >> ws; cin.getline(EmployeeName, 40); cout << "Address: "; cin >> ws; cin.getline(Address, 50); cout << "City: "; cin >> ws; cin.getline(City, 20); cout << "State: "; cin >> ws; cin.getline(State, 32); cout << "ZIP Code: "; cin >> ws; cin.getline(ZIPCode, 10); cout << "/nEnter the name of the file you want to create: "; cin >> FileName; ofstream EmplRecords(FileName, ios::out); EmplRecords << EmployeeName << "/n" << Address << "/n" << City << "/n" << State << "/n" << ZIPCode;*/// 2. Uncomment the following section to open an existing file/*cout << "Enter the name of the file you want to open: "; cin >> FileName; ifstream EmplRecords(FileName); EmplRecords.getline(EmployeeName, 40, '/n'); EmplRecords.getline(Address, 50); EmplRecords.getline(City, 20); EmplRecords.getline(State, 32); EmplRecords.getline(ZIPCode, 10); cout << "/n -=- Employee Information -=-"; cout << "/nEmpl Name: " << EmployeeName; cout << "/nAddress: " << Address; cout << "/nCity: " << City; cout << "/nState: " << State; cout << "/nZIP Code: " << ZIPCode;*/ cout << "/n/n"; return 0;}
Borland C++ Builder Version
//---------------------------------------------------------------------------#include <iostream>#include <fstream>#include <conio>using namespace std;#pragma hdrstop//---------------------------------------------------------------------------#pragma argsusedint main(int argc, char* argv[]){ char FileName[20]; char EmployeeName[40], Address[50], City[20], State[32], ZIPCode[10]; // 1. Uncomment the following section to create a new file/* cout << "Enter the Following pieces of information/n"; cout << "Empl Name: "; cin >> ws; cin.getline(EmployeeName, 40); cout << "Address: "; cin >> ws; cin.getline(Address, 50); cout << "City: "; cin >> ws; cin.getline(City, 20); cout << "State: "; cin >> ws; cin.getline(State, 32); cout << "ZIP Code: "; cin >> ws; cin.getline(ZIPCode, 10); cout << "/nEnter the name of the file you want to create: "; cin >> FileName; ofstream EmplRecords(FileName, ios::out); EmplRecords << EmployeeName << "/n" << Address << "/n" << City << "/n" << State << "/n" << ZIPCode;*/ // 2. Uncomment the following section to open an existing file/*cout << "Enter the name of the file you want to open: "; cin >> FileName; ifstream EmplRecords(FileName); EmplRecords.getline(EmployeeName, 40, '/n'); EmplRecords.getline(Address, 50); EmplRecords.getline(City, 20); EmplRecords.getline(State, 32); EmplRecords.getline(ZIPCode, 10); cout << "/n -=- Employee Information -=-"; cout << "/nEmpl Name: " << EmployeeName; cout << "/nAddress: " << Address; cout << "/nCity: " << City; cout << "/nState: " << State; cout << "/nZIP Code: " << ZIPCode;*/ cout <<"/n/nPress any key to continue..."; getch(); return EXIT_SUCCESS;}//---------------------------------------------------------------------------
- C++ File Processing〔fstream〕
- <C++>FILE和fstream
- C File Processing
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- C/C++文件输入输出操作——FILE*、fstream、windowsAPI
- Google中国渠道变阵 上海火速成总代首选
- 利用Eclipse编辑中文资源文件
- duwamish例程读后感---引子
- WEB拖动DataGrid列[zt]
- 在powerdesigner9中建了pdm模型,想把它用word,RTF,HTM文档导出
- C++ File Processing〔fstream〕
- TValueListEditor 控件使用方法
- log4j补充
- axis + spring 集成
- Blog 与我
- Oracle 常用函数
- Javascript 算圆周率到小数点后100位
- Eclipse基础--使用links方式安装Eclipse插件
- 可爱的女友