Code:
int main()
{
char *name = (char*)malloc(50), *job = (char*)malloc(1000);
int id, info;
puts("Enter the ID:");
scanf("%d",id);
puts("Enter employee name:");
fgets(name,sizeof(name),stdin);
puts("Enter employee's duty:");
fgets(job,sizeof(job),stdin);
info = writeinfo(name,id,job); /* This function is contained in a header file of mine
but I don't think it has anything to do with the error anyway */
if(info!=0)
{
puts("Operation Failed");
return 1;
}
else
{
puts("Success!");
return 0;
}
}
What's happening is that it gets to the part where it says "Enter the ID:" and when I enter any number whatsoever it causes the error and crashes.