ansistring,ansistring get's by compiler

C

crash

I have a program that i changed over from using char *'s to using
ansistrings. Previously it had been:

char string1[255];
char string2[255];
strcpy(string1,string2);


now i use:

AnsiString string1;
AnsiString string2;
string1 = string2;

The problem is, i made a mistake and didn't completely convert a line,
and it was like this:

AnsiString string1;
AnsiString string2;
string1,string2;

I did not get any error for this. I found it by stepping through the
code and noticing that this line was completely jumped over, almost
like it was a comment. I'm not sure if this is IDE specefic or
language specific, but can anyone tell me if they know why this makes
it by the compiler? I use Borland C++ Builder 6. Thanks in advance
for your help,

Ben
 
C

Colander

I have a program that i changed over from using char *'s to using
ansistrings. Previously it had been:

char string1[255];
char string2[255];
strcpy(string1,string2);

now i use:

AnsiString string1;
AnsiString string2;
string1 = string2;

The problem is, i made a mistake and didn't completely convert a line,
and it was like this:

AnsiString string1;
AnsiString string2;
string1,string2;

I did not get any error for this. I found it by stepping through the
code and noticing that this line was completely jumped over, almost
like it was a comment. I'm not sure if this is IDE specefic or
language specific, but can anyone tell me if they know why this makes
it by the compiler? I use Borland C++ Builder 6. Thanks in advance
for your help,

Because the , is an operator, so the line is quite valid, it does the
following;

it will evaluated it's arguments from left to right and the total
expression evaluates to the last argument; The goal is to be able to
combine multiple expressions as one.

example:

int j = length;
for(int i = 0; i < length; i++, j--) {
}
 
L

Lionel B

I have a program that i changed over from using char *'s to using
ansistrings.

What's Ansistring? Any particular reason for not using the C++
std::string class?

[...]
The problem is, i made a mistake and didn't completely convert a line,
and it was like this:

AnsiString string1;
AnsiString string2;
string1,string2;

I did not get any error for this.

No, because it's valid[1] C++ (although it probably[1] doesn't do
anything).

[1] assuming Ansistring is not completely insane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top