【笔记】c++文件

1、文件。

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <ctime>
#include <cstdlib>
using namespace std;
char *ch = "qwertyuiopasdfghjklzxcvbnm"; void setOut(string dataType) {
string out = dataType + ".data";
freopen(out.c_str(), "w", stdout);
} char *Random(char* word) {
int len = rand() % ;
for (int i = ; i != len; ++i)
word[i] = ch[rand()% + ];
word[len] = '\0';
return word;
} void make() {
srand(unsigned(time()));
char word[];
for (int i = ; i != ; ++i) {
cout << Random(word) << endl;
}
} int main() {
setOut("Random");
make();
return ;
}

从文件读,写入文件:

void setIO(string in, string out) {
freopen(in.c_str(), "r", stdin);
freopen(out.c_str(), "w", stdout);
}
上一篇:Java Annotation探究(二)


下一篇:Visual C# 2008大学教程pdf 文档分享