Ask for help in C language

Hello there!
I’m looking for help in this task. I’ve got it and it has to be done last week but I’ve tried everything (as I know) but it did not help, so if you can solve it, I’ll be very grateful for it.

This is the task:

In this task, the student shall complete the missing function. There is a half-finished program with a function for the output of information to be created.

An example of formatting printing:

ID: 1300 - Terrace Drive 1555
SalesRep: John Camembert
Promised Intrest Rate: 3.51

Only items that are not sold (object-> sold == 0) are to be printed.

And here is the program:

#include <stdio.h>
#include <stdlib.h>

struct sales
{
int object_id;
char name[64];
char sales_rep[64];
double given_intrest_rate;
uint8_t sold;
};

struct sales houses[] =
{
{1298, “Terrace Drive 1223”, “Gwendolyn Toth”, 3.44, 0},
{1299, “Fourth Road 1223”, “Gwendolyn Toth”, 3.31, 1},
{1300, “Terrace Drive 1555”, “John Camembert”, 3.51, 0},
{1301, “Centric Lane 2388”, “John Camembert”, 3.48, 1},
{1302, “Centric Lane 1998”, “John Camembert”, 3.63, 1},
{1303, “Outroff Road 1116”, “Gwendolyn Toth”, 3.37, 0},
{1305, “Suffork Ranch”, “Steven Crown”, 3.61, 1},
{1306, “Fourth Road 1123”, “Steven Crown”, 3.62, 1},
{1307, “Terrace Drive 1955”, “Steven Crown”, 3.37, 0},
{NULL, NULL, NULL, NULL, NULL}
};

void print_all_objects_not_sold(struct sales* objects)
{
/*

              Enter your code here

*/
}

int main()
{
print_all_objects_not_sold(&houses);

return 0;
}

 Thanks in advance :smiley:

Hi @mikelalloush,

This appears to be homework. We want to help you get the information you need, but we also are concerned that just giving you the answer will rob you of the necessary skills you’ll need to develop. If you can describe the things you’ve tried and how they haven’t worked for you, perhaps someone can give you a nudge in the right direction.

Cheers!

1 Like

Hi @nadiajoyce

That is absolutely right. 

what i tried is:

{
struct sales *ptr = NULL;
ptr = houses;
int i;

for ( i =0;i< 8;i++) {
if (ptr->sold == NULL)
break;
if (sold[i].sold == 0)
printf(“ID: %d - %s\nSalesRep: %s\nPromised Intrest Rate: %f\n”,
ptr->object_id,
ptr->name,
ptr->sales_rep,
ptr->given_intrest_rate);
}
ptr = houses;

}

 and the complire gave me 1 error and 2 warnings:

in line 48 void print_all_objects_not_sold(struct sales* houses, struct sales* sold) 

   Note: expected struct sales * but argument is of type struct sales (*)[10].

in line 48 void print_all_objects_not_sold(struct sales* houses, struct sales* sold)

  Note: declared here.

in line 71 print_all_objects_not_sold(&houses);

 Error: too few arguments to function ‘print_all_objects_not_sold’

in line 71 print_all_objects_not_sold(&houses);

  Warning: passing argument 1 of ‘print_all_objects_not_sold’ from incompitable pointer

though I have not changed anything in them.

and in line 56  if (ptr->sold == NULL)

  Warning: comparison between pointer and integer.

Thanks alot for the tips