Question: Using C language, codeblocks. Create struct for cars. struct cars{ char score[2]; int name; }; struct cars* allocate() { /*Allocate memory for 8 cars*/ cars
Using C language, codeblocks.
Create struct for cars.
struct cars{ char score[2]; int name; };
struct cars* allocate() {
/*Allocate memory for 8 cars*/ cars *array_of_cars[8] = (cars *)malloc(sizeof(cars)); /*return the pointer*/ return &cars[0]; }
Errors: unknown type name 'cars' 'cars' undeclared (first use in this function)| each undeclared identifier is reported only once for each function it appears in|
Issue seems to be that "cars" is undeclared struct within the scope of the second function. But I need to return pointer of type cars.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
