我想打印c中结构的元素,但send和third打印语句给了我警告:格式指定类型'char *',但参数具有类型'char'。我知道它与指针有关,但我不知道我做错了什么。我也修改了它以显示我正在使用的2个结构。打印结构中的项目
struct student_record{
int student_id;
int student_age;
char first_name;
char last_name; };
struct student_record_node{
struct student_record* record;
struct student_record_node* next;
struct student_record_node* prev; };
void printNode(struct student_record_node *node){
printf("Struct student_record_node: \n");
printf(" student first_name: %s\n", node->record->first_name);
printf(" student last_name: %s\n", node->record->last_name);
printf(" student id: %d\n", node->record->student_id);
printf(" student age: %d\n", node->record->student_age);
printf("\n");}
显示结构声明。 – Barmar
它与指针没有任何关系。错误消息说'first_name'和'last_name'被声明为'char',而不是'char [some_size]'或'char *'。 – Barmar
你确定你得到第三个'printf'的错误,而不是前两个?顺便说一句,最后一个'printf'在结尾处缺少'';' –