0

hello,

i want to pass an array and 2 more integer elements in the routine of thread in pthread in c.

i know i need to use structure for the same. i am using pointer to that structure in this case.

i need to know--- what will happen if i make changes on the array which i have passed in the routine of the thread?

will the changes reflect in the actual array. i know if we pass by reference in normal function, changes will reflect. But will it reflect in this case also? and what will happen if i make changes on those 2 integer elements?

or am i supposed to return changed array to make changes.

Drew.

Edited by drewangel: n/a

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Salem
0

If I tell you that it will reflect, would it make you brave enough to try to compile a piece of code for yourself?

0

actually i have never used threading in c. my program is giving me some errors. i will solve them neways.

but i need to know this thing, so i could build my logic that what exactly i am supposed to do.

0

> i know i need to use structure for the same. i am using pointer to that structure in this case.
Do you allocate this struct (good), or use some local variable (bad), or even re-use that local variable for starting more threads (even worse!).

Ditto for the array.
So long as it's only ONE thread using the array for the lifetime of the thread, there's nothing much to worry about.

> my program is giving me some errors.
Posting actual error messages and short examples we can try is a good idea....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.