This should be allowed as long as you name the file .cpp and not C and build using a C++ compiler.
From your C includes and using C syntax to declare a struct and C function "printf" I suspect that you are trying to define a function inside struct in a C program
Got it. Changed the name of the file, and it worked. thank you. can u explain the reason for it? is that a wrong way to declare in C but a valid one in c++?
Got it. Changed the name of the file, and it worked. thank you. can u explain the reason for it? is that a wrong way to declare in C but a valid one in c++?
Functions in structures is a feature of C++, C specification does not have this concept. If you save the file as .c (even if the compiler is capable of compiling C++) the compiler will compile it as a C program.