Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions