Hello there,
I have written a structure as an example and I am having trouble compiling it... I don't see what is wrong with it I think it has to do with some other thing but I am not sure...
The code is as follows:
Code:
/*
* test1.c
*
* Created on: Feb 9, 2010
* Author
*/
#include <stdio.h>
#include <stdlib.h>
int main(void) {
struct employee {
char name[30];
char address[100];
int age;
float salary;
} emp1;
printf("Enter the name of the employee: ");
scanf("%s", emp1.name);
printf("Enter the address of the employee: ");
scanf("%s", emp1.address);
printf("Enter the age of the employee: ");
scanf("%d", &emp1.age);
printf("Enter the salary of the employee: ");
scanf("%f", &emp1.salary);
printf("the age of emp1 is: %s\n", emp1.name);
printf("the age of emp1 is: %s\n", emp1.address);
printf("the age of emp1 is: %d\n", emp1.age);
printf("the salary of emp1 is: %f\n", emp1.salary);
return 0;
}
and I get this as an output:
Enter the name of the employee: Enter the address of the employee: Enter the age of the employee: Enter the salary of the employee: the age of emp1 is: ץ0wM
the age of emp1 is: '
the age of emp1 is: 77
the salary of emp1 is: 0.000000
Please can anyone help me? is there something wrong with the code?
-------------------------------------------------
windows vista x64 ultimate
eclipse-SDK-3.5.1-win32
mingw-w32-bin_i686-mingw_20100123_sezero
MSYS-1.0.11