我有创建文本文件的程序并写入一些随机符号。如何使线程写出这些符号?这是我的代码:
static void MyThreadProc(){}
static const char alphanum[] = "0123456789";//this is random symbols I'm using
int stringLength = sizeof(alphanum) - 1;
char genRandom() {
return alphanum[rand() % stringLength];
}
int main() {
String^ fileName = "file.txt";
StreamWriter^ sw = gcnew StreamWriter(fileName);
srand(time(0));
Thread^ myThread1 = gcnew Thread(gcnew ThreadStart(MyThreadProc));
Thread^ myThread2 = gcnew Thread(gcnew ThreadStart(MyThreadProc));
//Here I create my threds
for (int z = 0; z < 21; z++){//This cycle writes 21 random simbol
// myThread1->sw->WriteLine(genRandom());
// myThread1->sw->WriteLine(genRandom()); this threads I want to start writing symbols
sw->WriteLine(genRandom()); //write random symbols
}
sw->Close();
}
答案 0 :(得分:0)
此代码使用线程将符号写入文本文件:
=DLookUp("[Letter]","[Grades]","" & Nz([AVG],-1) & " Between [ArtsLow] And [ArtsHigh]")