Let's say I have the following struct and two versions to initialize it:
#include <stdio.h>
typedef struct Car *CarPtr;
typedef struct Car {
const char* name;
unsigned int price;
} Car;
int main(void) {
Car ford = {
.name = "Ford F-150",
.price = 25000
};
print_struct(&ford);
// is this possible to do in a single assignment?
CarPtr jeep = {
.name = "Jeep",
.price = 40000
};
print_struct(jeep);
}
Is the second version possible to do directly? Or do I need to do something along the lines of:
CarPtr jeep;
jeep->name = "Jeep";
jeep->price = 40000;
Or what's the proper way to initialize the CarPtr
type directly?