Here is the program I am working on. It is very simple and is going to be used for a school project... but I am getting an error on my character function. Here is the code.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define WAIT 999999999
int wait(void);
char menu(char com[30]);
FILE *fp;
int main()
{
char Name[20], Pass[20], File[30];
char Fpass[20], Fname[20], command[30];
int suffix = '.txt';
printf("Enter the name of the file: ");
scanf("%s", &File);
if(strchr(File, suffix))
{
fp = fopen(File, "r");
}
else
{
printf("*Error* \nMake sure to put the suffix at the end of the file name!\n");
printf("Ending program...");
}
printf("Enter name: ");
scanf("%s", &Name);
printf("Enter pass: ");
scanf("%s", &Pass);
fscanf(fp,"%s", &Fname);
if(strcmp(Name, Fname) != 0)
{
printf("Either the user or the password is incorrect!\n");
printf("Ending program...");
wait();
system("exit");
}
fscanf(fp,"%s", &Fpass);
if(strcmp(Pass, Fpass) != 0)
{
printf("Either the user or the password is incorrect!\n");
printf("Ending program...");
wait();
system("exit");
}
printf("Logging in...\n");
wait();
do{
printf("Command: ");
scanf("%s", &command);
menu(command);
command = menu();
}while(strcmp(command, "quit") != 0);
}
int wait(void)
{
int x;
for(x = 0; x < WAIT; x++)
;
return x;
}
char menu(char com[30])
{
char com[30];
if(strcmp(com, "user") == 0)
{
char New_user[20], New_pass[30];
printf("Enter username: ");
scanf("%s", &New_user);
fscanf("Enter password: ");
scanf("%s", &New_pass);
printf("Creating new user...");
fscanf(fp, "%s\n", &New_user);
fscanf(fp, "%s\n", &New_pass);
fscanf(fp, "----------------");
printf("Done!\n");
}
return com;
}
I am getting an error on line 7... too few arguments to function 'char menu(char*)
line 53: at this point in file
" : incompatible types in assignment of 'char' to 'char[30]' in function 'char menu(char*)';
line 65: declaration of 'char com[30] shadows a paramter
" : [warning] address of local variable 'com' returned
line 71: cannot convert 'const char*' to 'FILE*' for argument '1' to 'int fscanf(FILE*, const char*,...)'
line 79: invalid conversion from 'char*' to 'char'
These are all the errors verbatim that I received in the program, any help would help ALOT! Thanks all