I keep getting the warnings such as
"warning: passing argument 2 of ‘strcmp’ makes pointer from integer without a cast" about strcmp and strdup. I'm pretty new to C and I feel like I've tried a million things with no luck...I don't really get what's going on.
Any help would be really appreciated :)
printf("switch to menu driven mode\n");
int exit = 0;
char input;
char username[50],password[50],type[50];
while(exit == 0)
{
printf("MAIN MENU - type the first letter of your command\n===================\n(a)dd\n(d)el\n(e)dit\n(v)erify\n(q)uit\n");
scanf("%c", &input);
switch(input)
{ // a switch based on the input - cases for each possible input.
case 'a': // adds a new username/password/type tuple to the text file.
printf("\nEnter a new username to add:");
fgets(username,50,stdin);
getchar();
printf("\nEnter a password:");
fgets(password,50,stdin);
getchar();
printf("\nEnter a type:");
fgets(type,50,stdin);
getchar();
int k, compare;
for(k = 0; k<100;k++)
{
compare = strcmp(info[k].user, username);
if(compare == 0) // username is found
{
printf("username already exists.\n");
break;
}
}
char newInfo[50];
strcpy(newInfo, strdup(username));
strcat(newInfo, ",");
char newPass[50];
strcpy(newPass, strdup(password));
strcat(newInfo, newPass);
strcat(newInfo, ",");
strcat(newInfo, type);
printf("The new info is %s", newInfo);
break;