+ 1
whats wrong in my code not giving desire output in vs code
3 ответов
+ 2
Maybe because you define
int n;
struct emp employ[n],*ptr;
in line 11 und 12.
But you get the input for n at line 15. I would say, that's to late.
+ 1
As near as I can tell you're trying to read into memory that you've used malloc() to allocate, and then you're trying to copy what you've read into an array.
First I'd pick a single approach. Either make sure the array is sized right (see Coding Cat 's suggestion) and just read directly into that, or don't have the array at all and just malloc() enough memory for n instances of your struct - and use ptr just like you'd use an array.
+ 1
thank you sir.