Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5339

runtime error with scanf function

$
0
0

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;

}

 

 


Viewing all articles
Browse latest Browse all 5339

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>