Well I gave you several things to change and you only changed two of them. Salary is still an array.
Does your compiler not warn you?
Well I gave you several things to change and you only changed two of them. Salary is still an array.
Does your compiler not warn you?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
but i'm declare the salary as the integer type ...i'm not sure which part you refer to and after i change the code become (id == P[i].id ) the compiler will straight print no record founded with this id.no matter id exit or not
Last edited by kkkcj; 12-18-2017 at 12:26 AM.
>but i'm declare the salary as the integer type ...i'm not sure which part you refer to and after i change the code become (id == P[i].id )
salary should not be an array type for the same reason you didn't make id an array type in the structure. The names are char arrays because they have to be, so what you do with them (like call strcpy) is a little different from things that can be expressed as one number.
I mean, presumably P is an array of employees, so each P[i] has everything about one employee; their name arrays, their salary integer, etc. If salary stays an int[20] it's just a lot of extra space when you only need one number.
"P" is a rather terrible variable name by the way for something so central to the program.
Last edited by whiteflags; 12-18-2017 at 01:16 AM.