I have been trying to get this code to compile but I keep getting the error. "error: expected declaration specifiers or ‘...’ before ‘*’ token" Please see the code below. I am using gcc 4.8.1
Code:
#include<stdio.h>
#include<stdlib.h>
#define N 1000000000
void add( *a, *b, *c ) {
int tid = 0; // this is CPU zero, so we start at zero
while (tid < N) {
c[tid] = a[tid] + b[tid];
tid += 1; // we have one CPU, so we increment by one
}
}
int main( void ) {
double *a = malloc(N*sizeof(double));
double *b = malloc(N*sizeof(double));
double *c = malloc(N*sizeof(double));
// fill the arrays 'a' and 'b' on the CPU
for (int i=0; i<N; i++) {
a[i] = rand();
b[i] = rand();
}
add( a, b, c );
free(a);
free(b);
free(c);
return 0;
}