Getting this error don't understand really what i need to do to trouble shoot...
hw.c: In function ‘PrintMatrix’:
hw.c:14: error: subscripted value is neither array nor pointer
hw.c: In function ‘main’:
hw.c:27: warning: passing argument 1 of ‘PrintMatrix’ makes integer from pointer without a cast

#include <stdio.h>
#include <pthread.h>


int size=0;

void PrintMatrix(int matrix){
  int i, j;
	// print A
	for(i = 0; i < size; i++)
	{
		for(j = 0; j < size; j++)
		{
			printf("%d ", matrix[i][j]);
		}
		printf("\n");
	}
	printf("\n\n");
}

main(int argc, char* argv[])
{   
  	size = atoi(argv[1]);
    int matrixA[size][size];
    int matrixB[size][size];
    int matrixC[size][size];
	PrintMatrix(matrixA);
	return 0;
	
}

Any help will be appreciated....

Getting this error don't understand really what i need to do to trouble shoot...
hw.c: In function ‘PrintMatrix’:
hw.c:14: error: subscripted value is neither array nor pointer
hw.c: In function ‘main’:
hw.c:27: warning: passing argument 1 of ‘PrintMatrix’ makes integer from pointer without a cast

#include <stdio.h>
#include <pthread.h>


int size=0;

void PrintMatrix(int matrix){
  int i, j;
	// print A
	for(i = 0; i < size; i++)
	{
		for(j = 0; j < size; j++)
		{
			printf("%d ", matrix[i][j]);
		}
		printf("\n");
	}
	printf("\n\n");
}

main(int argc, char* argv[])
{   
  	size = atoi(argv[1]);
    int matrixA[size][size];
    int matrixB[size][size];
    int matrixC[size][size];
	PrintMatrix(matrixA);
	return 0;
	
}

Any help will be appreciated....

You are declaring that your function expects a single integer to be passed to it here:

void PrintMatrix(int matrix)

but you are trying to pass it a two dimensional array here:

int matrixA[size][size];
PrintMatrix(matrixA);

These are incompatible types. You should change your PrintMatrix function so that it takes a two dimensional array of integers as a parameter rather than an integer.

its been awhile i apologize brain kind of fried tonight..
but than i have it empty and give me an incomplete array type?

int i,j;
int matrix[0][0];
void PrintMatrix(int matrix [i] [j])
{
}

//in main
PrintMatrix(matrixA[size][size]);

this is probably very trivial but its been awhile since ive done c/c++ and can't really think at the moment.. thanks for the help. i greatly appreciate it

its been awhile i apologize brain kind of fried tonight..
but than i have it empty and give me an incomplete array type?

int i,j;
int matrix[0][0];
void PrintMatrix(int matrix [i] [j])
{
}

//in main
PrintMatrix(matrixA[size][size]);

this is probably very trivial but its been awhile since ive done c/c++ and can't really think at the moment.. thanks for the help. i greatly appreciate it

I'm not sure what you are trying to do here:

int matrix[0][0];

Are you trying to declare an array with no elements? I've never tried doing that so I don't know if it would actually give you an error or not, but why would you want to declare a 2-dimensional array with no elements?

use "pointer" to define ur function like this
void PrintMatrix(int *matrix);
and it will work good!

well kinda like in java you have a placeholder in the method in order to call it in the main that is what matrix basically is... and i attempt to use point and it still gives me an issue. i honestly forgot how to use them.

#include <stdio.h>
#include <pthread.h>

int matrixA[0][0];
int matrixB[0][0];
int matrixC[0][0];
int size=0;

void PrintMatrix(int *matrix[][]){
  int i, j;
	// print A
	for(i = 0; i < size; i++)
	{
		for(j = 0; j < size; j++)
		{
			printf("%d ", &matrix[i][j]);
		}
		printf("\n");
	}
	printf("\n\n");
}

main(int argc, char* argv[])
{   
  	size = atoi(argv[1]);
     //matrixA[size][size];
     matrixB[size][size];
     matrixC[size][size];
	PrintMatrix(matrixA[size][size]);
	return 0;
	
}

Well, it's not a placeholder. You are defining arrays with no rows and no columns. There is no place for data. So once you try to put anything in your arrays, you overwrite memory changing data you shouldn't and will definitely screw up the program and probably crash.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.