Reputation: 105
So this is the first time I have used scanf() for input, and I have no idea what is causing this error. It seems like the array of characters is not being recognized as the correct data type because it has a max length, but as far as I know there is no other way to declare a string in c... Here is the code:
#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 System\n\n");
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 Input\n");
}
Upvotes: 1
Views: 675
Reputation: 145899
Change &time
to time
in scanf
call.
s
conversion specifier requires a pointer to char
but you are passing a pointer to an array of char
.
Upvotes: 4