I'm trying to make a function which will receive a char *
from the user and will print it.
It turns my value to something weird when I'm printing it.
**//input method**
char* readContactName(){
char tmp[20];
do{
printf("What is your contact name?: (max %d chars) ", MAX_LENGH);
fflush(stdin);
scanf("%s", &tmp);
} while (!strcmp(tmp, ""));
return tmp;
}
void readContact (Contact* contact)
{
char* tmp;
tmp = readContactName();
updateContactName(contact, tmp);
}
**//when entering this function the string is correct**
void updateContactName(Contact* contact, char str[MAX_LENGH])
{
printf("contact name is %s\n",&str); --> prints rubish
}
What did I miss here?