Well, I have a bizarre error. It works now except that it prints out "Input:" twice. I tried putting a previous printf() call before that one to see if it would print "Input"+"mynewprintfmsg"+"Input" but it didn't... only when it calls THAT exact printf does it print out the extra "Input"
Code:
do{
printf("Input:");
res = fgets(input,MAX_ILEN,stdin);
fflush(stdin);
formatstr(input);
if(strcmp(input,"cuser")==0){
while(iname[0] == 0){
printf("Enter Name:");
scanf("%s",iname);
if(strlen(iname)>MAX_NLEN){
printf("Error try again (max length = 30).\n");
memset(&iname,0,MAX_NLEN);
}
}
while(ipwd[0] == 0){
printf("Enter Password:");
scanf("%s",ipwd);
if(strlen(ipwd)>MAX_PLEN){
printf("Error try again (max length = 30).\n");
memset(&ipwd,0,MAX_PLEN);
}
}
//cuser(iname,ipwd);
memset(&iname,0,MAX_NLEN);
memset(&ipwd,0,MAX_PLEN);
memset(&input,0,MAX_ILEN);
}
}while(res != NULL && ((strcmp(input,"quit")!=0)));
I have a feeling it could do with the memset() calls I'm doing but I'm not sure. memset() them all to 0 should be ok right?
I tried changing them to for loops and setting them that way but it didn't fix the problem so I don't know