473,324 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

PROBLEM: why can't auto-covert char [10][10] into char **

Hi All,

char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?

Regards
-Wisdo
Aug 18 '06 #1
21 2257

void print(char (*p)[128], int len)

definition should fix your problem. Functions that have 2 dimensional
arrays
as arguments need a hint to be able to offset the arrays properly. This
is
because these are arrays of arrays actually.

Hope this helps,

Tolga Ceylan

Aug 18 '06 #2
Wisdo <wi***@hf.webex.comwrote:
Hi All,

char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?
Yes, char[][] is not the same as a char**. 'sex' isn't a pointer to a
pointer to a char.
Aug 18 '06 #3

"Wisdo" <wi***@hf.webex.comwrote in message
news:ec**********@news.yaako.com...
Hi All,

char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?

Regards
-Wisdo
Because char [10][10] is not an array of pointers, it is a two dimentional
array of characters.
The memory is allocated and used about the same way as char [100] and you
can test that yourself.

This prints out Male and Female twice. Pick the one you like best.

void print( const char p[][128], const int length )
{
for ( int i = 0; i < length; ++i )
std::cout << &p[i][0] << std::endl;
}

void print2( const char* p, const int width, const int length )
{
for ( int i = 0; i < length; ++i )
std::cout << &p[width * i] << std::endl;
}

int main()
{
char sex[2][128] = {"Male", "Female" };
print( sex, 2 );
print2( reinterpret_cast<const char *>( sex ), 128, 2 );
}
Aug 18 '06 #4
Wisdo posted:
Hi All,

char [10][10] to char ** is compile error. why?

Type mismatch, both before and after the array-to-pointer decay.

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

Incorrect -- arrays yield well-defined behaviour in C++.

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?

Your speech is unintelligible.

Here's some sample code:

#include <cstddef>
#include <cassert>
#include <iostream>

using std::cout;
using std::size_t;

#define restrict /* Nothing */
#define nullptr 0 /* Until next standard */

size_t const buflen = 64;

void PrintNullTerminatedArrayOfPointersToStrings(char const *const restrict
*restrict p)
{
assert(p);
assert(*p);

do cout << *p++ << '\n';
while(*p);
}

void PrintNullTerminatedArrayOfStrings(char const *restrict p)
{
assert(p);
assert(*p);

do cout << p << '\n';
while(*(p += buflen));
}

int main()
{
char const *const restrict names1[] = {
"Michael","John","Philip","Barry","Thomas",
"Luke","Owen","Richard","Keith",nullptr};

char const names2[][buflen] = {
"Michael","John","Philip","Barry","Thomas",
"Luke","Owen","Richard","Keith", {0} };

PrintNullTerminatedArrayOfPointersToStrings(names1 );

PrintNullTerminatedArrayOfStrings(*names2);
}

--

Frederick Gotham
Aug 18 '06 #5
In article <ec**********@news.yaako.com>, Wisdo <wi***@hf.webex.comwrote:
>Hi All,

char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?
The problem is that you do not have an array of pointers,
you have an array or array's, so something like sex[1][2]
has to get to the right group of [128]'s. It's not sure
what you want here, but perhaps you want to pass each
sex[i] and accept a char * instead.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 18 '06 #6
In article <ec**********@panix2.panix.com>,
Greg Comeau <co****@comeaucomputing.comwrote:
>In article <ec**********@news.yaako.com>, Wisdo <wi***@hf.webex.comwrote:
>>char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?

The problem is that you do not have an array of pointers,
you have an array or array's, so something like sex[1][2]
has to get to the right group of [128]'s. It's not sure
what you want here, but perhaps you want to pass each
sex[i] and accept a char * instead.
Oops if not obvious "array or arrays" should say "array of arrays"
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 18 '06 #7

to***********@yahoo.com wrote:
void print(char (*p)[128], int len)
Yet another reason to just use the standard classes to your advantage
is that rather convoluted and entirely necissary definition.

Aug 18 '06 #8
Wisdo wrote:
Hi All,

char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?

Regards
-Wisdo
Simply, one (IMHO) convenient way to implement the print function is to
use template:

#include <iostream>

using namespace std;

template <size_t N>
void print(char p[][N], int len)
{
for(int i = 0 ; i < len ; ++i)
{
cout << p[i] << endl;
}
}

int main()
{
char sex[2][128] = {"Male", "Female" };
print(sex, 2);
return 0;
}

Pierre
Aug 18 '06 #9
Noah Roberts posted:
>void print(char (*p)[128], int len)

Yet another reason to just use the standard classes to your advantage
is that rather convoluted and entirely necissary definition.

I see nothing convoluted about it, but then again I'm not afraid of C++.

--

Frederick Gotham
Aug 18 '06 #10
"Wisdo" <wi***@hf.webex.comwrote in message
news:ec**********@news.yaako.com...
Hi All,

char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?

Regards
-Wisdo
Of course, since this is a c++ group, need to give you a modern equivalent.
(code snippets which I hope contain no typos)

#include <string>
#include <vector>

std::vector<std::stringSex;

void print( std::vector<std::string>& p )
{
for ( std::vector<std::string>::iterator it = p.begin(); it != p.end();
+it )
std::cout << *it << std::endl;
}

Sex.push_back("Male");
Sex.push_back("Female");
Aug 19 '06 #11
In article <1g************@newsfe03.lga>, ta*******@rocketmail.com
says...

[ ... ]
#include <string>
#include <vector>
A couple minor omissions:
#include <iostream>
#include <iterator>

Though I'd include <algorithinstead of <iterator...
std::vector<std::stringSex;

void print( std::vector<std::string>& p )
{
for ( std::vector<std::string>::iterator it = p.begin(); it != p.end();
+it )
std::cout << *it << std::endl;
}
And then I'd use:

void print(std::vector<std::string const &p) {
std::copy(p.begin(), p.end(),
std::ostream_iterator<std::string>(std::cout, "\n"));
}

Or perhaps even:

std::ostream &
operator<<(std::ostream &os, std::vector<std::stringconst &v) {
std::copy(v.begin(), v.end(),
std::ostream_iterator<std::string>(os, "\n"));
return os;
}

int main() {
std::vector<std::stringSex;

Sex.push_back("Female");
Sex.push_back("Male");

std::cout << Sex;
return 0;
}

--
Later,
Jerry.

The universe is a figment of its own imagination.
Aug 19 '06 #12
Greg Comeau дµÀ:
In article <ec**********@panix2.panix.com>,
Greg Comeau <co****@comeaucomputing.comwrote:
>In article <ec**********@news.yaako.com>, Wisdo <wi***@hf.webex.comwrote:
>>char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?
The problem is that you do not have an array of pointers,
you have an array or array's, so something like sex[1][2]
has to get to the right group of [128]'s. It's not sure
what you want here, but perhaps you want to pass each
sex[i] and accept a char * instead.

Oops if not obvious "array or arrays" should say "array of arrays"
I want to know why C/C++ forbidden the covertion from char[][] to char **p.

as many guys said, the char [12][12] and char ** are different types,
and of course can't covert into each other.

but in C/C++, the char [12] and char *p are the same expect the latter
lost the length information.
i.e. in C/C++,

void f(char *p, int len);
char s[7] = "array";
f(s, 7); <-- it's OK.

but if we consider the same thing in two-dimenstion

void f(char **p, int with, int height);
char s[2][128] = { "Male", "Female" };
f(s, 2, 128); <-- this need auto-convertion from char[2][128] to char**
, but it's forbidden in C/C++.

I'm interesed in the regular design about C/C++ about this ban,
it's forbidden and what it want to avoid?
-Wisdo


Aug 20 '06 #13
Frederick Gotham дµÀ:
Wisdo posted:
>Hi All,

char [10][10] to char ** is compile error. why?


Type mismatch, both before and after the array-to-pointer decay.
yes, they are type mismatch.
but whether they are type mismatch depends the type conversion rule.
if the two types can't convert into each other, then they are type mistach.

char [10] and char * are also differnet type, but we can do this

void print(char *p, int len);
char s[10] = "arrayStr";
print(p);

and we can't do this in 2-dimension.
void print(char **p, int w, int h);
char ss[2][10] = { "str1", "str2" };
print(p, 2, 10);

it's surprising, and i could ask why can't do this.
and the answer is they are mismatch.
so why char [10][10] and char ** are mismatch,
but char[10] and char * are not mismatch?

Maybe it's a little about the tradeoff of language design.
and i really want to know why he make the decision like this.
>
>if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.


Incorrect -- arrays yield well-defined behaviour in C++.

>void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?


Your speech is unintelligible.

Here's some sample code:

#include <cstddef>
#include <cassert>
#include <iostream>

using std::cout;
using std::size_t;

#define restrict /* Nothing */
#define nullptr 0 /* Until next standard */

size_t const buflen = 64;

void PrintNullTerminatedArrayOfPointersToStrings(char const *const restrict
*restrict p)
{
assert(p);
assert(*p);

do cout << *p++ << '\n';
while(*p);
}

void PrintNullTerminatedArrayOfStrings(char const *restrict p)
{
assert(p);
assert(*p);

do cout << p << '\n';
while(*(p += buflen));
}

int main()
{
char const *const restrict names1[] = {
"Michael","John","Philip","Barry","Thomas",
"Luke","Owen","Richard","Keith",nullptr};

char const names2[][buflen] = {
"Michael","John","Philip","Barry","Thomas",
"Luke","Owen","Richard","Keith", {0} };

PrintNullTerminatedArrayOfPointersToStrings(names1 );

PrintNullTerminatedArrayOfStrings(*names2);
}
Regards
-Wisdo
Aug 20 '06 #14
Wisdo <wi***@hf.webex.comwrote:
Greg Comeau wrote:
>In article <ec**********@panix2.panix.com, Greg Comeau
<co****@comeaucomputing.comwrote:
>>In article <ec**********@news.yaako.com, Wisdo
<wi***@hf.webex.comwrote:

char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to
use vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?
The problem is that you do not have an array of pointers, you
have an array or array's, so something like sex[1][2] has to get
to the right group of [128]'s. It's not sure what you want here,
but perhaps you want to pass each sex[i] and accept a char *
instead.

Oops if not obvious "array or arrays" should say "array of arrays"

I want to know why C/C++ forbidden the covertion from char[][] to
char **p.

as many guys said, the char [12][12] and char ** are different
types, and of course can't covert into each other.

but in C/C++, the char [12] and char *p are the same expect the
latter lost the length information. i.e. in C/C++,

void f(char *p, int len); char s[7] = "array"; f(s, 7); <-- it's
OK.

but if we consider the same thing in two-dimenstion

void f(char **p, int with, int height); char s[2][128] = { "Male",
"Female" }; f(s, 2, 128); <-- this need auto-convertion from
char[2][128] to char** , but it's forbidden in C/C++.

I'm interesed in the regular design about C/C++ about this ban,
it's forbidden and what it want to avoid?
The question you want answered really should be asked in comp.std.c++. However, from what I know, the compiler can't make the conversion you
ask for because it doesn't keep track of the start location of each
start point for the second dimension.
Aug 20 '06 #15
* Wisdo:
>
why char [10][10] and char ** are mismatch,
but char[10] and char * are not mismatch?
First, why this OK:

char a[10];
char* p = a; // OK

Here 'p' is initialized to point to first element of 'a'.

When you dereference 'p', the expression '*p', you have a reference to
the first element of 'a', and you can use that value or assign to it.

Now consider

typedef char* CharPointer;
CharPointer ahum[10];
char** pp = ahum; // OK

This is also OK. 'ahum' is an array of 10 char* pointers, and 'pp' is a
pointer to char*. 'pp' is initialized to point to the first element of
'ahum', which is a char* pointer just like all other elements of 'ahum'.

Finally consider

char argh[10][10];
char** pp = argh; // NOT OK.

'pp' is a pointer to char*, but is initialized to point to a char[10]
array (the first element of 'argh' is a char[10] array). So if you
store a char* pointer value in '*pp', you'll be storing a pointer value
in a 'char' or a number of 'char' values, depending on the size of a
pointer in that C++ implementation. Ordinarily that would be an error,
and C++ protects you against that by checking the types you use.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Aug 20 '06 #16
In article <ec**********@news.yaako.com>, Wisdo <wi***@hf.webex.comwrote:
>as many guys said, the char [12][12] and char ** are different types,
and of course can't covert into each other.

but in C/C++, the char [12] and char *p are the same expect the latter
lost the length information.
IOWs, they are not the same. There is in C and C++ what
can be considered an anomaly. In short, we can do this:

char c = 'x';
char a[] = "blah";
char *p;

and then both of these will work:

p = &c;
p = a;

Neither of these is probably surprising, but, it's easy to think
or say in the second case "p points to the array a". The "problem"
is that of course it is only pointing to the first character of a.
After all, p is declared as pointer to A char. A as in one.

The type of a is char[5]. In some (most) circumstances, it get
CONVERTED to a char *. This means information is indeed lost.

This is a problem, because we have the notion of incementing a pointer.
However, this is not a good idea:

p = &c;
p++; // Huh?

Nor even this:

char one[1] = { 'c' };
p = one;
p++; // Yikes!

IOWs, things such as bounds checking are not a requirement
upon an implementation or the code it generates.o

This happens at even level of indirection, but usually because
we normally stay in the level we're in the collapsing of the most
immediate dimension is seen as reasonable while those at others are not.

So, this would not seem reasonable:

char a2[4][5];

p = a2;

EVEN THOUGH, the programmer may have just wanted to travese
the 20 char for some reason. You can of course cast the assignment
to a char *, but then you're on your own, even more so than normal.
Not only do you loose the most immediate dimension but you loose both.
Normally that's too much lost and so normally becomes an error to
be allowed to happen implicitly. After all, you made it a 2d array
instead of a 1d array for some reason. So with a2 normally you'd
want to be dealing with each char[5] (a2[0], a2[1], a2[2], a2[3], a2[4]).
or each char (a2[x][y]) and not changing it into some other shape.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 20 '06 #17
In article <ec**********@panix1.panix.com>,
Greg Comeau <co****@comeaucomputing.comwrote:
>In article <ec**********@news.yaako.com>, Wisdo <wi***@hf.webex.comwrote:
>>as many guys said, the char [12][12] and char ** are different types,
and of course can't covert into each other.

but in C/C++, the char [12] and char *p are the same expect the latter
lost the length information.

IOWs, they are not the same. There is in C and C++ what
can be considered an anomaly. In short, we can do this:

char c = 'x';
char a[] = "blah";
char *p;

and then both of these will work:

p = &c;
p = a;

Neither of these is probably surprising, but, it's easy to think
or say in the second case "p points to the array a". The "problem"
is that of course it is only pointing to the first character of a.
After all, p is declared as pointer to A char. A as in one.

The type of a is char[5]. In some (most) circumstances, it get
CONVERTED to a char *. This means information is indeed lost.

This is a problem, because we have the notion of incementing a pointer.
However, this is not a good idea:

p = &c;
p++; // Huh?

Nor even this:

char one[1] = { 'c' };
p = one;
p++; // Yikes!

IOWs, things such as bounds checking are not a requirement
upon an implementation or the code it generates.o

This happens at even level of indirection, but usually because
we normally stay in the level we're in the collapsing of the most
immediate dimension is seen as reasonable while those at others are not.

So, this would not seem reasonable:

char a2[4][5];

p = a2;

EVEN THOUGH, the programmer may have just wanted to travese
the 20 char for some reason. You can of course cast the assignment
to a char *, but then you're on your own, even more so than normal.
Not only do you loose the most immediate dimension but you loose both.
Normally that's too much lost and so normally becomes an error to
be allowed to happen implicitly. After all, you made it a 2d array
instead of a 1d array for some reason. So with a2 normally you'd
want to be dealing with each char[5] (a2[0], a2[1], a2[2], a2[3], a2[4]).
or each char (a2[x][y]) and not changing it into some other shape.
OOps, my examples used char * and not char ** but the gist of points
made should still hold.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 20 '06 #18

"Wisdo" <wi***@hf.webex.comwrote in message
news:ec**********@news.yaako.com...
Greg Comeau дµÀ:
>In article <ec**********@panix2.panix.com>,
Greg Comeau <co****@comeaucomputing.comwrote:
>>In article <ec**********@news.yaako.com>, Wisdo <wi***@hf.webex.com>
wrote:
char [10][10] to char ** is compile error. why?

if i hava a string array. yes. it's not safe and it's better to use
vector<stringinstead.

but my point is the language feature.

char sex[2][128] = {"Male", "Female" };

void print(char **p, int len) {
// print all sex
}

print(sex, 128); // <--- this cause compile error.

Is any issue to make the language forbiden this covertion?
The problem is that you do not have an array of pointers,
you have an array or array's, so something like sex[1][2]
has to get to the right group of [128]'s. It's not sure
what you want here, but perhaps you want to pass each
sex[i] and accept a char * instead.

Oops if not obvious "array or arrays" should say "array of arrays"

I want to know why C/C++ forbidden the covertion from char[][] to char
**p.

as many guys said, the char [12][12] and char ** are different types,
and of course can't covert into each other.

but in C/C++, the char [12] and char *p are the same expect the latter
lost the length information.
i.e. in C/C++,

void f(char *p, int len);
char s[7] = "array";
f(s, 7); <-- it's OK.

but if we consider the same thing in two-dimenstion

void f(char **p, int with, int height);
char s[2][128] = { "Male", "Female" };
f(s, 2, 128); <-- this need auto-convertion from char[2][128] to char**
, but it's forbidden in C/C++.

I'm interesed in the regular design about C/C++ about this ban,
it's forbidden and what it want to avoid?
char MyArray[12][12];
MyArray is a pointer to 144 characters.

char** MyPArray;
MyPArray is a pointer to pointers.

You see the difference? Once points to characters, one points to ponters.
They are NOT the same.
MyArray[5][0] is a CHARACTER, not a pointer.
MyArray[5] is a pointer, but only by conversion.
Aug 20 '06 #19
In article <D4***************@newsfe05.lga>,
Jim Langston <ta*******@rocketmail.comwrote:
>char MyArray[12][12];
MyArray is a pointer to 144 characters.
You've overspoke :)

MyArray is a char[12][12] which is some cases is automatically
(implicitly) converted to a char (*)[12].
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 21 '06 #20
"Greg Comeau" <co****@panix.comwrote in message
news:ec**********@panix2.panix.com...
In article <D4***************@newsfe05.lga>,
Jim Langston <ta*******@rocketmail.comwrote:
>>char MyArray[12][12];
MyArray is a pointer to 144 characters.

You've overspoke :)

MyArray is a char[12][12] which is some cases is automatically
(implicitly) converted to a char (*)[12].
Yes, but I was actually trying to explain what they were pointing to in
memory, not how C++ treated them.

That char MyArray[12][12] points to 144 characters *in memory*.
char MyPArray**; points to an array of character pointers *in memory*.

The memory contents of what they point to is different, which is why you
can't have an automatic conversion, was the point I was trying to make (and
it appears rather badly).
Aug 21 '06 #21
In article <%e*************@newsfe07.lga>,
Jim Langston <ta*******@rocketmail.comwrote:
>"Greg Comeau" <co****@panix.comwrote in message
news:ec**********@panix2.panix.com...
>In article <D4***************@newsfe05.lga>,
Jim Langston <ta*******@rocketmail.comwrote:
>>>char MyArray[12][12];
MyArray is a pointer to 144 characters.

You've overspoke :)

MyArray is a char[12][12] which is some cases is automatically
(implicitly) converted to a char (*)[12].

Yes, but I was actually trying to explain what they were pointing to in
memory, not how C++ treated them.

That char MyArray[12][12] points to 144 characters *in memory*.
char MyPArray**; points to an array of character pointers *in memory*.

The memory contents of what they point to is different, which is why you
can't have an automatic conversion, was the point I was trying to make (and
it appears rather badly).
Then I'm not sure what you mean by "points to".
MyArray isn't a pointer. Is "is"/represents an array or arrays,
totalling 144 chars. And MyPArray doesn't necessarily point to
an array of character pointers. Also, the address of different
constructs may have the same value but be different things.
I think these are not nitpicks but important fundamental
distinguishments.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 22 '06 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Chris Online | last post by:
Hi all, I'm using C++ Builder5. I want to get data from an edit-box and send it to a development kit. The dev-kit can only receive char and no char* here's a part of my code: char* Data_byte...
30
by: Tim Johansson | last post by:
I'm new to C++, and tried to start making a script that will shuffle an array. Can someone please tell me what's wrong? #include <iostream.h> #include <string.h> int main () {...
5
by: spoilsport | last post by:
Ive got to write a multi-function program and I'm plugging in the functions but I keep getting this error from line 40. Im new to this and cant find an answer anywhere. Sam #include...
12
by: Lars Langer | last post by:
Hi there, I'm new to this C - never the less - I'm trying to search a string for the occurence of a substring - However, I'm not very succesful since my use of the strstr function always returns...
12
by: GRoll35 | last post by:
I get 4 of those errors. in the same spot. I'll show my parent class, child class, and my driver. All that is suppose to happen is the user enters data and it uses parent/child class to display...
3
by: aldonnelley | last post by:
Hi there. I'm just learning c++, and this is driving me nuts. I'm trying to save image files generated in a for loop with a filename built using strcat with: - a char base file name + a...
34
by: Perro Flaco | last post by:
Hi! I've got this: string str1; char * str2; .... str1 = "whatever"; .... str2 = (char *)str1.c_str();
4
by: Xavier Roche | last post by:
Hi folks, I have a probably rather silly question: is casting a char array in a char* a potential source of aliasing bug ? Example: a fonction returning a buffer taken in a circular buffer ...
6
Nepomuk
by: Nepomuk | last post by:
Hi there! I was trying something with strings in C++ and ran into a problem. I wanted to write a program to do the following task: Read two "string" inputs and combine them into a third "string"....
5
by: slizorn | last post by:
well the error i get is the title above: error C2664: 'searchTree' : cannot convert parameter 2 from 'const char *' to 'char' error is form this line searchTree(treeObj->root ,data1.c_str());...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.