Question: I'm working with C Programming. I got an error that said conflicting types for 'print_part' how can I fix it and still have both 'print_part'

I'm working with C Programming. I got an error that said conflicting types for 'print_part' how can I fix it and still have both 'print_part' functions?

how do I turn it into object oriented C++ ?

Here is the code

#include

#define SIZE 5

struct part{

char name[127];

long no;

double price;

};

void print_part(struct part p);

void print_part(struct part* p);

int main( )

{

struct part board;/* One "part" */

struct part inventory[SIZE];/* Array to hold SIZE "part"s */

int i;

for(i=0; i < SIZE; i++){/* Load the array of structures. */

sprintf(board.name,"I/O card #%d", i);

board.no = 157356 + i;

board.price = 97.50 + i*3;

inventory[i] = board;

}

print_part(&board);/* print_part( ) expects an address. */

printf(" ");

for(i=0; i < SIZE; i++){/* Display the array of structures. */

print_part(&inventory[i]);

printf(" ");

}

return 0;

}

void print_part(struct part* p)

{

printf("Product: %s ", (*p).name);

printf("Part No.: %ld ", (*p).no);

printf("Unit price: %.2f ", (*p).price);

return;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!