This part of my code is about signup.
I only can signup for one time, the next time the program stops.
What is the problem?
while (1) { /*usercounter initialized with 0*/
printf("enter your order:\n");
gets(buffer);
order = strtok(buffer, " ");
if (strcmp(order, "signup") == 0) {
usercounter++;
if (usercounter > 50) {
username=realloc(username,usercounter*sizeof(*username));
password=realloc(password, usercounter*sizeof(*password));
}
username[(usercounter - 1)] = (char *)malloc(50*sizeof(char));
strcpy(username[usercounter - 1], strtok(NULL, " "));
password[(usercounter - 1)] = (char *)malloc(50*sizeof(char));
strcpy(password[usercounter - 1], strtok(NULL, "\n"));
free(buffer);
continue;
}
}