所以这是我第一次使用scanf()进行输入,我不知道是什么导致了这个错误。似乎字符数组没有被识别为正确的数据类型,因为它有一个最大长度,但据我所知,没有其他方法可以在c中声明字符串…下面是代码:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "health.h"
Chartptr patientList = NULL; /* Define global variable patientList (declared in health.h) */
/* patientList is globaly accessible in health_util.c */
void main(){
printf("Welcome to the Health Monitoring Systemnn");
int id, type;
double value;
char time[MAXTIME + 1];
scanf("%d, %s, %d, %lf", &id, &time, &type, &value);
printf("--------------------------------------------------n");
printf("%s: Patient ID = %d checking in", time, id);
addPatient(id);
printf("--------------------------------------------------n");
printf("nEnd of Inputn");
}
在scanf
调用中将&time
更改为time
。
s
转换说明符需要指向char
的指针,但您正在传递指向char
数组的指针。