I am using MS VC++ '08, ad have run into a problem that stumps me :

void printtext(char **lotsoftext,int m,int n)
{
for(int i=0;i<n;i++)
  for(int j=0;j<m;j++)
    print(lotsoftext[i][j]);
}

The error is as follows :
cannot convert parameter 1 from 'char' to 'const char *'

How do i correctly refer to lotsoftext ?
Oh, and i don't want to use 2d arrays, so please don't tell me to do that. ;)

short answer : change

void printtext(char **lotsoftext,int m,int n)

to

void printtext(const char **lotsoftext,int m,int n)

Just a side note, when your function does not change the content of its arguments thats passed, then make
them const.

Thanks, that stopped the compilation errors atleast.

But suppose if i make a similar function that does change the array, how would I go about doing that?

For example,

void printtext(char **lotsoftext,int m,int n)
{
for(int i=0;i<n;i++)
  for(int j=0;j<m;j++)
    {
           print(lotsoftext[i][j]);
           if(i==2 && j==1)
              lotsoftext[i][j] = "Hello";
}

if it changes its values then your functions should have
a non const array as a parameter like so :

void printtext(char **lotsoftext,int m,int n)

but you cannot pass a const array to it because the function
does not promise not to change its content.

okay, thanks for helping so fast.

no problem. Mark this thread solved?

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.