История изменений
Исправление LINUX-ORG-RU, (текущая версия) :
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE * pfin = fopen(argv[1],"r");
FILE * pfout = fopen(argv[2],"w");
srand(time(NULL));
if(!pfin || !pfout)
{
fprintf(stderr, "need 2 arguments input file and output file\n");
exit(-1);
}
char buff[127]= {0};
while ( fgets(buff,125,pfin) )
{
int a = rand() % 20 + 1;
if(buff[a]=='-')
{
a++;
};
buff[a]='*';
fprintf(pfout,"%s",buff);
}
fclose(pfin);
fclose(pfout);
return 0;
}
dron@gnu:~$ gcc fff.c -o app && ./app ./a ./b ;cat b
SUQI-L*EI-3YJ4-J393-Z4RM
3JF0-XFSN-*PDY-AU7L-FBU8
Z*29-WZ2L-TIYL-S4LG-04UF
dron@gnu:~$
Но какой фообще смысл? Подобрать всего 1 символ сможет и Вася из 2б класса, тупо перебором лфавита и цифарок за 5 минут.
Исправление LINUX-ORG-RU, :
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE * pfin = fopen(argv[1],"r");
FILE * pfout = fopen(argv[2],"w");
srand(time(NULL));
if(!pfin || !pfout)
{
fprintf(stderr, "need 2 arguments input file and output file\n");
exit(-1);
}
char buff[127]= {0};
while ( fgets(buff,125,pfin) )
{
int a = rand() % 20 + 1;
if(buff[a]=='-')
{
a++;
};
buff[a]='*';
fprintf(pfout,"%s",buff);
}
fclose(pfin);
fclose(pfout);
return 0;
}
dron@gnu:~$ gcc fff.c -o app && ./app ./a ./b ;cat b
SUQI-L*EI-3YJ4-J393-Z4RM
3JF0-XFSN-*PDY-AU7L-FBU8
Z*29-WZ2L-TIYL-S4LG-04UF
dron@gnu:~$
Исходная версия LINUX-ORG-RU, :
Зачем любой? Нужно любой кроме '-' лул. Держи. Скриптота для лохов :D
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE * pfin = fopen(argv[1],"r");
FILE * pfout = fopen(argv[2],"w");
srand(time(NULL));
if(!pfin || !pfout)
{
fprintf(stderr, "need 2 arguments input file and outputfile\n");
exit(-1);
}
char buff[127]= {0};
while ( fgets(buff,125,pfin) )
{
int a = rand() % 20 + 1;
if(buff[a]=='-')
{
a++;
};
buff[a]='*';
fprintf(pfout,"%s",buff);
}
fclose(pfin);
fclose(pfout);
return 0;
}
dron@gnu:~$ gcc fff.c -o app && ./app ./a ./b ;cat b
SUQI-L*EI-3YJ4-J393-Z4RM
3JF0-XFSN-*PDY-AU7L-FBU8
Z*29-WZ2L-TIYL-S4LG-04UF
dron@gnu:~$