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.

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

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.

> 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....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.