01-08-2019 02:35 PM
Hello,
I am trying to create a simple console application and keep getting the following run-time error from the CVI compiler:
NON-FATAL RUN-TIME ERROR: "c:\CVI Programs\struct2.c", line 20, col 17, thread id 0x00004D6C: Parameter type mismatch; expecting pointer to char but found pointer to aggregate or userdefined.
It's talking about line 20 in my code. I don't get it, I have had no issues with this using the GCC compiler. Can anyone take a look? below is the code.
#include <stdio.h>
#include <string.h>
#define NAME_SIZE 40
struct employee
{
char name[NAME_SIZE];
char hireDate[15];
float salary;
};
int main (void){
struct employee hire1 = {"jimmy", "7/2/15" , 105000.00};
struct employee hire2;
printf("enter the employee's name\n");
scanf("%s", &hire2.name);
printf("enter the employee's hire date\n");
scanf("%s", &hire2.hireDate);
printf("enter the employee's salary\n");
scanf("%f", &hire2.salary);
printf("employee 1 info is name:%s, hire date:%d, salary:%f\n", hire1.name, hire1.hireDate, hire1.salary);
char c = getchar();
return 0;
}
Solved! Go to Solution.
01-08-2019 04:35 PM
You don't have to use the addressing operator ("&") when scanning strings. Your line must look this way:
scanf ("%s", hire2.name);