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;

Also, my entire program is pretty big, so I didn't want to post the whole thing - I have the rest of it formatted properly (I think).

Also, my entire program is pretty big, so I didn't want to post the whole thing - I have the rest of it formatted properly (I think).

That's OK, as long as what you post has the problem and we can read it. Please reformat the code. Can you actually read what you posted?

Alright, here's the full code (it's still hard to read, the formatting is getting a little messed up when I post it here)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include "menu.c"
int main(argc,argv)
int argc;
char *argv[];
{
	// opens the file and fills the users, passes, and types arrays
	struct {
    char user[50];
    char pass[50];
    char type[50];
  	}info[100];
  	FILE *fp;
  	char buf[100];
  	int i = 0, j;
  	fp=fopen("password.csv","r");

  	while( fgets(buf,sizeof(buf),fp) != NULL)
  	{
    	strcpy(info[i].user, strtok(buf,","));
    	strcpy(info[i].pass, strtok(NULL,","));
    	strcpy(info[i].type, strtok(NULL,","));
    	++i;
  	}

  	printf("print details\n");

  	for (j=0; j<10; j++)
  	{
    	printf("User : %s\n", info[j].user);
		printf("Pass : %s\n",info[j].pass);
		printf("Type : %s\n",info[j].type);
  	}
    //===========================================================
    
	printf ("This program is called %s\n",argv[0]);
	int result;
	if (argc > 1)
   	{
   		printf("argv[1] = %s\n",argv[1]);
   		result = strcmp(argv[1],"-menu");
   		if (result == 0)	// -menu is the first argument
   		{	
   				// THIS ENTIRE THING IS THE MENU.C FILE
				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;
						case 'd':
					
							break;
						case 'e':
					
							break;
						case 'v':
					
							break;
						case 'q':
							exit = 1;
							break;
						default:
							printf("Enter the first letter of one of the functions.\n");
							break;
					}
						getchar();	// Clear the buffer.
			   	} // END OF MENU.C
		}
			   	
   		else	// NOT menu driven mode
   		{
   			for (i = 2; i < argc; i++)
      		{
      			result = strcmp(argv[i],"-menu");
      			if (result == 0)	// exit, menu isn't first
   				{
   					printf("error: the syntax is as follows: $passweb –menu –add –del –edit –verify username password type user_2 pass_2 type_2");
   					return 0;
   				}
      		}
   		}
   	}
	else
   		printf("Command has no arguments\n");
   		
   	return 1;
}

The lines from 70 - 87 is the only place I'm really stuck right now, that's what's giving me the errors.

Alright, here's the full code (it's still hard to read, the formatting is getting a little messed up when I post it here)

Then read this.

And didn't I say it's OK to post only the code with the problem? You could just reformat that part so it can be understood.

Okay, here's the code, reformatted, for just the part that's giving me trouble.
Before, the code fine in my text editor, but the tabbing / spacing was changing when I pasted it in here.

Like I said, I'm very new to C, so there could be lots of errors that I'm making in here, not necessarily related to what I'm asking about, so don't hesitate to correct me :)

char input;
char username[50],password[50],type[50];
printf("\nEnter a new username to add:");
fgets(username,50,stdin);
printf("\nEnter a password:");
fgets(password,50,stdin);
printf("\nEnter a type:");
fgets(type,50,stdin);
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, username);
strcat(newInfo, ",");
strcat(newInfo, password);
strcat(newInfo, ",");
strcat(newInfo, type);
printf("The new info is %s", newInfo);

Okay, here's the code, reformatted, for just the part that's giving me trouble.
Before, the code fine in my text editor, but the tabbing / spacing was changing when I pasted it in here.

MUCH better. Be sure to read the link I posted. It will help you correct your TAB problem.

Like I said, I'm very new to C, so there could be lots of errors that I'm making in here, not necessarily related to what I'm asking about, so don't hesitate to correct me :)

Oh oh, free hand given. You are in real trouble now! :icon_wink:

char input;
char username[50],password[50],type[50];
printf("\nEnter a new username to add:");
fgets(username,50,stdin);    // Don't forget that FGETS keeps the \n entered.  You probably have to get rid of it before using STRCMP
printf("\nEnter a password:");
fgets(password,50,stdin);
printf("\nEnter a type:");
fgets(type,50,stdin);
int k, compare;        // This is C.  You need to create variables at the *top* of the code block, before executable statements.  Move this line up with the CHAR line.

And never tell us the error you get. Post the error exactly as the compiler shows it. And be sure we can tell what line the compiler is complaining about.

Thanks for the help so far. Here's the errors:

passweb2.c:70: warning: passing argument 2 of ‘strcmp’ makes pointer from integer without a cast
/usr/include/string.h:142: note: expected ‘const char *’ but argument is of type ‘char’
passweb2.c:79: warning: passing argument 1 of ‘strdup’ makes pointer from integer without a cast
/usr/include/string.h:173: note: expected ‘const char *’ but argument is of type ‘char’
passweb2.c:82: warning: passing argument 1 of ‘strdup’ makes pointer from integer without a cast
/usr/include/string.h:173: note: expected ‘const char *’ but argument is of type ‘char’
passweb2.c:85: warning: passing argument 2 of ‘strcat’ makes pointer from integer without a cast
/usr/include/string.h:135: note: expected ‘const char * __restrict__’ but argument is of type ‘char’

Also - strcmp is working - it finds it if it's a username that's already in the file, if it's not, it doesn't enter the if statement.

I repeat:

And be sure we can tell what line the compiler is complaining about.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.