I have 3 structures in my header file
struct{
int a;
int b;
} header;
struct{
int c;
int d;
} trailer;
struct{
header hdr;
trailer trl;
} msg_struct;
I declare an instance in my code
msg_struct new_msg;
After I populate new_msg, I then want to pass a pointer to new message to a special printFunc() I have written.
My call to the function
printFunc(&new_ msg);
HERE's My first problem -----
What should the function prototype look like in my header file for printFunc()
I have
printFunc(int *)
I get compiler error saying cannot convert int** to int* for argument 1.....
HERE's My second problem -----
In printFunc(), to cout the contents of new_msg, should the line read
std::cout<< new_msg->header.a << std::endl;
std::cout<< new_msg->header.b << std::endl;
etc........
This gives compiler "error expected unqualified-id before '.' token" which I assume means that it doesn't understand what the "new_msg->" is
Any help would be appreciated.
Thanks
emp1953
struct{
int a;
int b;
} header;
struct{
int c;
int d;
} trailer;
struct{
header hdr;
trailer trl;
} msg_struct;
I declare an instance in my code
msg_struct new_msg;
After I populate new_msg, I then want to pass a pointer to new message to a special printFunc() I have written.
My call to the function
printFunc(&new_ msg);
HERE's My first problem -----
What should the function prototype look like in my header file for printFunc()
I have
printFunc(int *)
I get compiler error saying cannot convert int** to int* for argument 1.....
HERE's My second problem -----
In printFunc(), to cout the contents of new_msg, should the line read
std::cout<< new_msg->header.a << std::endl;
std::cout<< new_msg->header.b << std::endl;
etc........
This gives compiler "error expected unqualified-id before '.' token" which I assume means that it doesn't understand what the "new_msg->" is
Any help would be appreciated.
Thanks
emp1953
Comment