Multiplying matrices: error: expected primary-expression before 'struct'

Posted by justin on Stack Overflow See other posts from Stack Overflow or by justin
Published on 2011-03-07T22:28:46Z Indexed on 2011/03/08 0:10 UTC
Read the original article Hit count: 273

Filed under:
|
|
|

I am trying to write a program that is supposed to multiply matrices using threads.
I am supposed to fill the matrices using random numbers in a thread. I am compiling in g++ and using PTHREADS. I have also created a struct to pass the data from my command line input to the thread so it can generate the matrix of random numbers. The sizes of the two matrices are also passed in the command line as well.

I keep getting: main.cpp:7: error: expected primary-expression before 'struct' my code @ line 7 =:

struct a{  
     int Arow;    
     int Acol;   
     int low;   
     int high;
 };

My inpust are :
Sizes of two matrices ( 4 arguments) high and low ranges in which o generate the random numbers between.

Complete code:

[headers]  
using namespace std;

void *matrixACreate(struct *);

void *status;


int main(int argc, char * argv[])
{ 


  int Arow = atoi(argv[1]); // Matrix A  
  int Acol = atoi(argv[2]); // WxX  
  int  Brow = atoi(argv[3]); // Matrix B  
  int Bcol = atoi(argv[4]); // XxZ,   
  int low = atoi(argv[5]); // Range low  
  int high = atoi(argv[6]);

struct a{
     int Arow; // Matrix A    
     int Acol; // WxX  
     int low; // Range low  
     int high;
 };


 pthread_t matrixAthread;
 //pthread_t matrixBthread;
 pthread_t runner;
 int error, retValue;

 if (Acol != Brow)
 {
     cout << " This matrix cannot be multiplied. FAIL" << endl;
     return 0;
 }

 error = pthread_create(&matrixAthread, NULL, matrixACreate, struct *a);  
 //error = pthread_create(&matrixAthread, NULL, matrixBCreate, sendB);  
 retValue = pthread_join(matrixAthread, &status);  
 //retValue = pthread_join(matrixBthread, &status);  

 return 0;
}
void matrixACreate(struct * a)
{
    struct a *data = (struct a *) malloc(sizeof(struct a));  
    data->Arow = Arow;  
    data->Acol = Acol;  
    data->low = low;  
    data->high = high;  
    int range = ((high - low) + 1);  
    cout << Arow << endl<< Acol << endl;  
    }// just trying to print to see if I am in the thread

© Stack Overflow or respective owner

Related posts about c++

Related posts about c