日期:2014-05-16 浏览次数:21043 次
1 #include<stdio.h>
2 #include<stdlib.h>
3
4 int main(){
5
6 system("touch filein");
7 for(int i=0;i<1001;i++)
8 system("echo $RANDOM >> filein");
9 return 0;
10
11 }
#!/bin/bash #在这里可以指定你的shell,我这里用的是bash echo "Hello,world!"
------解决方案--------------------
system("#/bin/ash echo $RANDOM");
------解决方案--------------------
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
extern int setenv(const char *,const char *,int);
int main(void)
{
char name[] = "RANDOM";
int cur;
system("touch file.lst");
srand(time(0));
if(getenv(name) == NULL)
{
for(int i=0;i<1001;i++)
{
char value[100];
cur=rand();
sprintf(value,"%d",cur);
if(setenv(name,value,1) != 0)
{
printf("error!!\n");
exit(1);
}
system("echo $RANDOM >> file.lst");
}
}
else
{
for(int i=0;i<1001;i++)
system("echo $RANDOM >> file.lst");
}
exit(0);
}