People, i've tried to understand how to input and print the data to structure with terminal by scanf function...but it`s not working. I'm going to have my exam on c, and it is hard to understand for me. My code is bellow. When i run the code it cause some warning, like
First-chance exception at 0x59473FD4 (msvcr120d.dll) in Project2.exe: 0xC0000005: Access violation writing location 0x00749000.
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
struct icx
{
char nameprod[20];
int year;
};
struct icx a;
int main(){
printf("Enter the data:\n");
scanf_s("%s%d", a.nameprod, &a.year);
printf("%s%d", a.nameprod, a.year);
_getch();
return 0;
}
Please I need your help.
User contributions licensed under CC BY-SA 3.0