Hey guys,
I'm stuck. Like everyone else posting in here I guess
Anyway, what I'm trying to do is really simple. I have a struct, and a function to modify any struct of the same type passed as param. That's the issue here... I know that I should be using pointers, but my app just refuses to compile!
I'm using the default C compiler that comes with Dev C++ 4.9.9.0.
Here goes my code:
This is insane! I get a few errors, but it all seems to be because of:Code:#include <stdio.h> #include <conio.h> struct Test { int a; int b; }; int main() { //create a test structure and assign values struct Test myTest; myTest.a = 10; myTest.b = -50; //Modify the test structure ModifyStruct(&myTest); //Display values printf("%d\t%d", myTest.a, myTest.b); getch(); //End program return 0; } //Function to modify a structure void ModifyStruct(struct Test * someTest) { someTest.a = 10; someTest.b = 10; }
32 C:\...\test.c request for member `a' in something not a structure or union
33 C:\...\test.c request for member `b' in something not a structure or union
Help!
I would appreciate an example with reference parameter passing with structs
-Rowan.