H
hotadvice
hello all
Consider this:
Suppose we have a an array of structure declared as following in
file1.c
structure foo{
.......
.......
.......
}FOO[50];
ie the above defines a structure foo ( and an array of type foo ).
Now in file2.c a function called FUNC needs to access this array.
How do i do it.??
What i tried (unsuccessfully though)---
-- re-define the structure foo (exactly as in file1.c) in file2.c .I
did this because i can not alter the file1.c and i do not have a header
file.
-- pass a pointer to array to FUNC
The above did not work,the size of the structure changes(when i gdb
through it)
as the control transfers from file1.c to file2.c
Though this worked:
-- re-define the structure foo (in the same way) in file2.c
-- passing the whole structure as an argument to FUNC.but this is
inefficient i suppose.
Got a better way??
Any suggestions are appreciated.
Thanx in advance.
Aman
Consider this:
Suppose we have a an array of structure declared as following in
file1.c
structure foo{
.......
.......
.......
}FOO[50];
ie the above defines a structure foo ( and an array of type foo ).
Now in file2.c a function called FUNC needs to access this array.
How do i do it.??
What i tried (unsuccessfully though)---
-- re-define the structure foo (exactly as in file1.c) in file2.c .I
did this because i can not alter the file1.c and i do not have a header
file.
-- pass a pointer to array to FUNC
The above did not work,the size of the structure changes(when i gdb
through it)
as the control transfers from file1.c to file2.c
Though this worked:
-- re-define the structure foo (in the same way) in file2.c
-- passing the whole structure as an argument to FUNC.but this is
inefficient i suppose.
Got a better way??
Any suggestions are appreciated.
Thanx in advance.
Aman