i need your help

hi guys i'm doin this program to verify if there are consonants in a char matrix but i have this problem at line 24 |24|error: invalid types 'char[int]' for array subscript|

and this |14|error: expected primary-expression before 'char'| at line 14

can you help me thanks;




#include <iostream>

using namespace std;
void find_consonant(char *matrix, char vector[], int n, int m);
int main()
{cout<<"inserisci dimensioni";
int n, m;
cin>>n; cin>>m;
char matrix[n][m];
char vector[5]={'a','e','i','o','u'};
for (int i=0; i<n; i++)
{for(int j=0; j<m; j++)
cin>>matrix[i][j];
find_consonant(char &matrice[0][0], vector[5], n, m);
}
}
void find_consonant()(char *matrix, char vector[], int n, int m)
{
for (int i=0; i<n; i++)
{for(int j=0; j<m; j++)
{
for(int l=0; l<5; l++)

if(matrix[i][j]!=vector[l])
cout<<"YES";
}
}
}
Last edited on
Please use code blocks when you post code, like so:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>

using namespace std;

void find_consonant ( char * matrix, char vector[], int n, int m );

int main ( )
{
	cout << "inserisci dimensioni";
	int n, m;
	cin >> n >> m;

	char matrix[n][m];
	char vector[5] = {'a','e','i','o','u'};

	for ( int i = 0; i < n; i++ )
	{
		for ( int j = 0; j < m; j++ )
			cin >> matrix[i][j];

		find_consonant ( char & matrice[0][0], vector[5], n, m );
	}
}

void find_consonant ( char * matrix, char vector[], int n, int m )
{
	for ( int i=0; i<n; i++ )
	{
		for ( int j = 0; j < m; j++ )
		{
			for ( int l = 0; l < 5; l++ )
				if ( matrix[i][j] != vector[l] )
					cout << "YES";
		}
	}
}


line 13: arrays cannot be dynamically created this way

line 21: Your function takes 'char * matrix', but you are trying to give it 'char & matrice[0][0]'
note: 'char * matrix' is the same as 'char matrix[]'


Is this for school or are you trying to learn how to code by yourself?
Last edited on
Topic archived. No new replies allowed.