man .C is tough .. anyway why is this not working ?? why do i have to declare char login[50]; instead of char *login; ? what is the difference between both of them? i thought it's the same
Code:
char *randstr()
{
static char tempstr[6];
char rnd;
/* Set evil seed (initial seed) */
srand( (unsigned)time( NULL ) );
for (int i = 0; i < 6; i++) {
rnd = ((float) rand()/RAND_MAX) * 25 + 97;
tempstr[i] = rnd;
}
tempstr[6] = '\0';
// printf("%s\n",tempstr);
return tempstr;
}
int main()
{
char *login; <--- here
strcpy(login,"NICK ");
strcat(login,randstr());
strcat(login," 8 * :abe abe\n");
printf("login var = %s",login);
return 0;
}