four strings are in a 2-D array; use strchr to find characters a, b, c, respectively;
search results are to be put in another 2-D arrray ter[ ][ ]:
results of searching 'a' in the 1st string go to ter[0][0], 'b' to ter[0][1]...
... 2nd string to to ter [1][0], 'b' to ter[1][1]...
...
here are the codes:
...
[code=c] int i, k;
char str[4][6]={"adevf", "dcdhn", "oledc", "brdca"};
char chr[3]={'a', 'b', 'c'};
char ter[i][3];
for (i=0; i<4; i++)
{
for (k=0; j<3; k++);
{
&ter[i][k] = strchr(str[i], chr[k]);
}
}[/code]
...
when compiling, line 10 is "invalid lvalue in assignment".
when using (ter[i]+k) = strchr(str[i], chr[k]); - same error.
So I guess the used the wrong pointer. Actually, I was confused.
What is wrong?
search results are to be put in another 2-D arrray ter[ ][ ]:
results of searching 'a' in the 1st string go to ter[0][0], 'b' to ter[0][1]...
... 2nd string to to ter [1][0], 'b' to ter[1][1]...
...
here are the codes:
...
[code=c] int i, k;
char str[4][6]={"adevf", "dcdhn", "oledc", "brdca"};
char chr[3]={'a', 'b', 'c'};
char ter[i][3];
for (i=0; i<4; i++)
{
for (k=0; j<3; k++);
{
&ter[i][k] = strchr(str[i], chr[k]);
}
}[/code]
...
when compiling, line 10 is "invalid lvalue in assignment".
when using (ter[i]+k) = strchr(str[i], chr[k]); - same error.
So I guess the used the wrong pointer. Actually, I was confused.
What is wrong?
Comment