I'm getting a lot of problems with a piece of code I'm writing. I'm not exactly sure whats wrong either.
Here's the code I'm trying:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[]) {
char pass[10];
FILE *fp;
char username[10];
system("clear");
printf("\nWelcome to Sign-Up Testing.");
printf("\nWhat UserName would you like?");
printf(" Max 10 characters.");
printf("\n\n>>>");
scanf("%s", &username);
fp = fopen("%s.dgf", username,"r");
if(fp != NULL) {
printf("\n%s is already taken.\n");
sleep(1);
return 0;
}
else if(fp == NULL){
fopen("%s.dgf", username,"w");
printf("\nPassword:\n");
scanf("%s", &pass);
fprintf(fp,"%s", pass);
printf("\nThank you for signing up!");
}
return 0;
}
Here's what Terminal told me.
Sign-Up.c: In function ‘main’:
Sign-Up.c:15:2: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[10]’ [-Wformat]
Sign-Up.c:16:2: error: too many arguments to function ‘fopen’
/usr/include/stdio.h:273:14: note: declared here
Sign-Up.c:18:3: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat]
Sign-Up.c:23:3: error: too many arguments to function ‘fopen’
/usr/include/stdio.h:273:14: note: declared here
Sign-Up.c:25:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[10]’ [-Wformat]