I have the following function in my code to extract names:
void student_init(struct student *s, char *info) {
char *name;
char *name2;
char a[] = { *info };
name = strtok(a, "/");
strcpy(s->first_name, name);
name2 = strtok(NULL, "/");
strcpy(s->last_name, name2);
}
When I run this, I see:
Please enter a student information or enter "Q" to quit.
Daisy/Lee
A student information is read.: Daisy/Lee
Please enter a row number where the student wants to sit.
1
Please enter a column number where the student wants to sit.
2
The seat at row 1 and column 2 is assigned to the student: D . �
?.?. ?.?. ?.?.
?.?. ?.?. D.�.
?.?. ?.?. ?.?.
I am trying to use the strtok function in a c program to split a string with "/" to separate a fist and last name and store them in the first_name and last_name variables of a student strcuture. I can get the first name stored in the respective variable but as you can see from the image in the link above I am getting a ? symbol in the output where the first initial of the last name should be.