Me and my friend is using structs in our code (our code is separate from each other). Lets take the following example:
struct Book {
char title;
int pages;
}
void setBook(struct Book *tempBook) {
tempBook->title = "NiceTitle";
tempBook->pages = 50;
}
The above code is pretty straight forward. The thing is, is there any difference in having these two mains:
int main() {
struct book obj1;
setBook(&obj);
}
Or
int main() {
struct Book *obj2;
setBook(obj2);
}
EDIT: I was not clear in my statement. I have initialized the pinter to
struct Book *obj2 = malloc(sizeof(struct obj2));