0
如何访问在runner函数中main()中动态声明的变量和矩阵。 我将它们作为参数传递给runner,但我不确定它是否正确,因为我必须在pthread_create函数调用中传递runner。我将不得不将所有参数传递给跑步者吗?我该怎么做 ?如何在调用另一个函数时传递函数的参数?
main() {
int m, n, p, q
int **a, **b, **c;
... // dynamically allocating first, second and multiply matrices and taking values
// m , n , p , q from user or a file.
...
r= pthread_create(threads[i], NULL, runner, (void*) &rows[i]);} // should I specify the
// parameters of runner in it ?
void *runner (int **a, int **b, int **c, int m, int n, int p) // is it right ???
{
.... using all parameters
pthread_exit(NULL);
}
另外,在你的结构中,你可以简单地持有一个指向你的数据的指针,而不是整个矩阵本身的副本,因为它是在main中动态创建的。 – 75inchpianist 2013-02-19 16:03:53
谢谢,我明白了,我会尽力实现它 – Learner 2013-02-19 16:12:11