int main()
{
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int rslt, n;
float sum = 0;
scanf("%d", &n);
int *tri = (int*)malloc(n * 3 * sizeof(int));
if(tri == NULL){
return 1;
}
printf("%d\n", *(tri[0]));
when I am referencing the tri pointer then it is showing the error. invalid type argument of unary '*'. thanks for the answer. The above part is clarified but I have another issue. but I have another issue
int main()
{
int rslt, n;
float sum = 0;
scanf("%d", &n);
int *tri = (int*)malloc(n * 3 * sizeof(int));
if(tri == NULL){
return 1;
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 3; j++)
{
scanf("%d", &(tri[j]));
}
printf("\n");
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 3; j++)
{
sum += tri[j] / 2;
printf("%d %d\n",sum,tri[j] / 2);
}
}
printf("%d\n",sum);
return 0;
}
when I am printing the tri[j] it is showing some garbage value.