Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to assign a calculated value into a structure location but i am gett

ID: 3705059 • Letter: I

Question

I am trying to assign a calculated value into a structure location but i am getting the error assign to expression with array type. If i use strcpy, i get an error of make pointer from integer without cast. Ideally i would like the keep the number and integer as i have to do some math problems later on in the program.

for(position=0;position<numRacers;position++)

{

points_rewarded = 20 - position;

if (points_rewarded < 0);

{

points_rewarded = 0;

}

database[position].pointsRewarded = points_rewarded;

printf("%d ",database[position].pointsRewarded);

}

Explanation / Answer

// assuming your structure is something like this struct s { int position; }; // If your array is something like then your code should not give any errors struct s database[10]; // Your array definition might be something like this, which is an array of pointer objects struct s *database[10]; If that is the scenario then you should use pointer notation -> to set properties database[position]->pointsRewarded = points_rewarded; printf("%d ",database[position]->pointsRewarded); // If not you need to post struct and how you are instantiating the array // with out that we can not see what the error is

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote