I'm trying to store a string with a first and last name from a string into a struct but I'm getting (warning: passing argument 1 of strcpy makes pointer from integer without a cast), and I'm not sure on where to put strcpy tried putting it in the while loop got the error which makes sense. But not sure on where to place strcpy EDITED
struct trip
{
char first_name;
char last_name;
}
int main(void)
{
struct trip travel[12];
}
char input_name(struct trip travel[MAXTRIP], int index)
{
int name_read, length;
int name_bytes = 100;
char *name, *word;
getchar();
printf("Please enter name:\n");
name = (char *)malloc(name_bytes + 1);
name_read = getline (&name, &name_bytes, stdin);
word = strtok(name, ",");
while (word != NULL)
{
strcpy(travel[index].first_name, word);
word = strtok(NULL, ",");
}
}
word? What isname? How have you declared your variables? Are you actually getting that error message?strcpyisn't used anywhere in your program.strcpyshown above and you don't show what most of your variables are.first_nameandlast_nameas single characters. The error is from the character being promoted to integer when passed tostrcpy.