"%s expects argument of type char *, but argument 3 has type char (*)[9]"

  • 本文关键字:char type argument has expects of but c
  • 更新时间 :
  • 英文 :


所以这是我第一次使用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数组的指针。

相关内容

最新更新