#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
void* findSin(void *arrayTwoD)
{
float **myArray = ((float **)arrayTwoD);
float total = 0.0;
int x = 0;
float *radAngle;
for (int data = 0; data < 2; data++)
{
*radAngle = *(*(myArray + data) + 0); <---This is triggering the error
for (int i = 1; i < 15; i += 2)
{
total += pow(*radAngle, i) / findFactorial(i);
}
printf("\nSin %f is %f \n", *myArray[data], total);
}
pthread_exit(0);
}
int main()
{
pthread_t threadid1;
float angleDegree;
float angleRadian;
float myArray[2][2];
for (int i = 0; i < 2; i++)
{
printf("Please enter the angle in degree: ");
scanf("%f", &angleDegree);
angleRadian = (angleDegree / 180.0) * M_PI;
myArray[i][0] = angleRadian;
}
pthread_create(&threadid1, NULL, findSin, (void *)myArray);
pthread_join(threadid1, NULL);
}
**请帮助我,我一直在试图弄清楚如何正确访问元素。谢谢。
情况:二维数组的第一列包含用户输入的角度。函数 findSin 使用第一列来查找相关元素的 sin 值。我无法访问第一列的元素**
错误:分段错误(核心转储)