Starglider 4
2010-04-15 23:13:51 UTC
i've got a basic function to generate a list of product activation codes,
into a .txt file:
const int no_keys=200;
int keys[no_keys],key_start=0;
double key_fac=7415379421725.7259638214256;
void make_keylist()
{
int _x;
double fac_=key_fac,_y;
for(int i=0;i<no_keys;i++)
{
_x=i+key_start+1;
_y=double(_x)*fac_;
_y=abs(_y);
// while(_y>=1000000.0)_y-=1000000.0;
keys[i]=int(_y);
}
char co[80];
FILE *stream;
fopen_s(&stream,"keylist.txt","w");
for(int i=0;i<no_keys;i++)
{
_x=keys[i];
_itoa_s(_x,co,80,10);
char *co2=strcat(co,"\n");
fwrite(co2,sizeof(char),strlen(co2),stream);
}
fclose(stream);
}
the problem is that the resulting .txt file displays a list
of 200 of exactly the same negative codes.
i really don't understand what i'm doing wrong here.
please help me out.
MK
into a .txt file:
const int no_keys=200;
int keys[no_keys],key_start=0;
double key_fac=7415379421725.7259638214256;
void make_keylist()
{
int _x;
double fac_=key_fac,_y;
for(int i=0;i<no_keys;i++)
{
_x=i+key_start+1;
_y=double(_x)*fac_;
_y=abs(_y);
// while(_y>=1000000.0)_y-=1000000.0;
keys[i]=int(_y);
}
char co[80];
FILE *stream;
fopen_s(&stream,"keylist.txt","w");
for(int i=0;i<no_keys;i++)
{
_x=keys[i];
_itoa_s(_x,co,80,10);
char *co2=strcat(co,"\n");
fwrite(co2,sizeof(char),strlen(co2),stream);
}
fclose(stream);
}
the problem is that the resulting .txt file displays a list
of 200 of exactly the same negative codes.
i really don't understand what i'm doing wrong here.
please help me out.
MK