c语言 dos命令

来源:百度知道 编辑:UC知道 时间:2024/07/05 04:45:45
我得到一个6位随机数,存在变量s中 我想把s中的数填在dos命令
system(“net user wang s中的数”)从而修改wang用户的密码
怎么做

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

long t;
char d[256];
char temp[2];
long s;
char c[256];
char buffer[100];
FILE* pFile;
char b[256] = "net user wang ";

char* long_to_string(const long s,char* source)
{
source[0] = 0;
t = s;
temp[1] = 0;
while(t)
{
temp[0] = t%10 + '0';
strcpy(d,source);
strcpy(source,temp);
strcat(source,d);
t/=10;
}
while(strlen(source)<6)
{
temp[0] = '0';
strcpy(d,source);
strcpy(source,temp);
strcat(source,d);
}
return source;
}

int main()
{
srand(time(NULL));
s = (rand()*37)%1000000;
s = (rand()*37)%1000000;
s = (rand()*37)%1000000;
s = (rand()*37)%1000000;
strcpy(buffer,long_to_string(s,c));
pFile = fopen(