As part of a decent size project I am doing for school I need to zero an entire array of structures although was having a lot of trouble, could anyone please point me in the right direction?
void zerorecord(employee a[]) //given an array zero all digits of each entry
{
for(int i=0;i<10;i++)
{
for(int k=0;k<20;k++)
{
a[i].name[k]='\0';
}
for(int j=0;j<12;j++)
{
a[i].sales[j]=0;
}
}
}
I am unsure of how to pass the array directly which is what I need to do. I am attempting to make all 10 e.name arrays equal '\0' initially then make all 12 e.sales for each of them 0 initially.
Here is a link to the full program(I am not posting it directly because I feel most of it wont be needed): http://pastebin.com/m57349eee
Currently the program will compile although it gives a run time error immediatly after running (which I assume to be due to the comparison to a value that isnt assigned; something I think might be corrected once I fix my function.
All help will be greatly appreciated.
Sadly I think I would get a 0 for that method. Our course is really retarded and we aren't allowed to use (proper) methods that aren't found in the textbook. The method I have attempted above is following their rough guidlines, although I need to find a way to reference.
Sorry that was my fault. that was an old version of paste bin, the current one has 10 instead of n. It compiles fine in the current build. It opens fine, and runs fine until
Where the error comes in is when it runs the else if (not unusual since none of the will initially be equal to a name since it is zero'd/blank). Do you think it is that my zerorecord function isnt passing the structures back to the main?