#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int main() {
char command[1000];
char fileName[100];
char fileContent[100];
while(1) {
cout << "Enter command: ";
cin.getline(command, 1000);
if(strncmp(command, "create", 6) == 0) {
sscanf(command, "create %s %[^\n]", fileName, fileContent);
FILE* file = fopen(fileName, "w");
if(file != NULL) {
fputs(fileContent, file);
fclose(file);
cout << "File created successfully" << endl;
} else {
cout << "Error creating file" << endl;
}
} else if(strncmp(command, "read", 4) == 0) {
sscanf(command, "read %s", fileName);
FILE* file = fopen(fileName, "r");
if(file !=
C++ 简单文件管理系统
最新推荐文章于 2024-07-12 10:45:15 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)