It seems that I can not save a global variable any help? Here is the part of the code that seems to be the trouble: PS: the (#include
are included)
#include <stdio.h>
#include <string.h>
void signup_user(char nameuser[10], char suruser[10],
char addressu[20], char usernameu[10],
char passuser[5]);
extern char nameuser[10] = "", suruser[10] = "",
addressu[20] = "", usernameu[10] = "",
passuser[5] = "";
int main {
signup_user(nameuser, suruser, addressu, usernameu, passuser);
}
void signup_user(char nameuser[10], char suruser[10],
char addressu[20], char usernameu[10],
char passuser[5]) { //synarthsh signup
printf("give name: ");
scanf(" %s", &nameuser); //dinei onoma
printf("give surname: ");
scanf(" %s", &suruser); //dinei epitheto
printf("give address: ");
scanf(" %s", &addressu);
printf("give username: ");
scanf(" %s", &usernameu); //dinei username
printf("give password: ");
scanf(" %s", &passuser);
}
CodePudding user response:
Your code will not compile. Do not use keywords you do not understand (extern
).
Format your code properly. Learn about arrays and pointers.
#include <stdio.h>
#include <string.h>
void signup_user(char *, char *,char *, char *, char *);
char nameuser[10]="", suruser[10]="",
addressu[20]="", usernameu[10]="", passuser[5]="";
int main(void )
{
signup_user(nameuser, suruser, addressu, usernameu, passuser);
}
void signup_user(char nameuser[10], char suruser[10], char addressu[20], char usernameu[10], char passuser[5])
{
printf("give name: ");
scanf(" %9s", nameuser);//dinei onoma
printf("give surname: ");
scanf(" %9s", suruser);//dinei epitheto
printf("give address: ");
scanf(" s", addressu);
printf("give username: ");
scanf(" %9s", usernameu);//dinei username
printf("give password: ");
scanf(" %4s", passuser);
}
Also you should check the return value of scanf