Reputation: 23
I've got a code where I should use some functions,one of them has a prototype like this: void writeR(RESISTOR) and the other like this: void write(RESISTOR *,int) The writeR function should be called inside the write function,but I don't know how to use it because I have a pointer type RESISTOR in all functions besides the writeR. Should I make a new value type RESISTOR without a pointer and then call that function or something else?
P.S. the writeR function is called to input the resistance and the resistor no. and is being used in loop.
P.P.S. this is the error I get when I try to compile the program Severity Code Description Project File Line Suppression State Error C4700 uninitialized local variable 'otp1' used
void write(RESISTOR *otp, int n)
{
RESISTOR otp1;
int i;
printf("\nRB. KATALOSKI BROJ R");
printf("\n--- --------------- ----------\n");
for (i = 0; i < n; i++)
{
printf("%2d.",i + 1);
writeR(otp1);
}
}
Upvotes: 1
Views: 99
Reputation: 210876
Use indirection operator *
to access the structur your pointer references.
void write(RESISTOR *otp, int n)
{
int i;
printf("\nRB. KATALOSKI BROJ R");
printf("\n--- --------------- ----------\n");
for (i = 0; i < n; i++)
{
printf("%2d.",i + 1);
writeR(*otp);
// ^^^
}
}
Upvotes: 2