new Line escape Sequences not interpreted

  • Thread starter Thread starter mattD
  • Start date Start date
M

mattD

hello all,

so here's my question are escape sequences only interpreted by the
compiler and not in the program itself. Here is a striped down example
of what brought this up.

this is a class i wrote to make a square out of astrisks based on an int
you give it.

---start driver for testing----
<HEADER STUFF>
int _tmain()
{
STUFF TO GET int num AND CHECKIT.
WHERE num IS YOUR int THE SIDE OF YOUR SQUARE
THAT ALL WORKS FINE.

//HERE's WHERE THE SQUARE GETS MADE AND DRAWN TO SCREEN.
//AND THE PROBLEM AREA.
Console::WriteLine(squ->SquareString(num));

return 0;
---end driver for testing----

---start squ class---
<CONSTRUCTOR STUFF>

String *MSquare::SquareString(int squareSide)

STUFF TO MAKE ARRAY AND FILL IT WITH "*" AND "\n" WHERE NEEDED.
THAT ALL WORKS FINE.

//turn array into string and send it
//PROBLEM AREA.
for(int cnt2 = 0; cnt2 < arraySquare->Length; cnt2++)
{
strSqu = String::Concat(strSqu, arraySquare[cnt2]);
}
return (strSqu);
---end squ class---

So if the side of your square is 4 the return statement in the class
above returns a String that looks like ****\n****\n****\n**** to the
Console::WriteLine(squ->SquareString(num)) in the driver test app.
and that is what gets printed to the screen.
****\n****\n****\n****
when i was expecting this.
****
****
****
****

Thanks,
mattD
 
mattD said:
hello all,

so here's my question are escape sequences only interpreted by the
compiler and not in the program itself. Here is a striped down example of
what brought this up.

this is a class i wrote to make a square out of astrisks based on an int
you give it.

---start driver for testing----
<HEADER STUFF>
int _tmain()
{
STUFF TO GET int num AND CHECKIT.
WHERE num IS YOUR int THE SIDE OF YOUR SQUARE
THAT ALL WORKS FINE.

//HERE's WHERE THE SQUARE GETS MADE AND DRAWN TO SCREEN.
//AND THE PROBLEM AREA.
Console::WriteLine(squ->SquareString(num));

return 0;
---end driver for testing----

---start squ class---
<CONSTRUCTOR STUFF>

String *MSquare::SquareString(int squareSide)

STUFF TO MAKE ARRAY AND FILL IT WITH "*" AND "\n" WHERE NEEDED.
THAT ALL WORKS FINE.

//turn array into string and send it
//PROBLEM AREA.
for(int cnt2 = 0; cnt2 < arraySquare->Length; cnt2++)
{
strSqu = String::Concat(strSqu, arraySquare[cnt2]);
}
return (strSqu);
---end squ class---

So if the side of your square is 4 the return statement in the class above
returns a String that looks like ****\n****\n****\n**** to the
Console::WriteLine(squ->SquareString(num)) in the driver test app.
and that is what gets printed to the screen.
****\n****\n****\n****
when i was expecting this.
****
****
****
****

Thanks,
mattD

You might try "****\r\n****\r\n****\r\n****\r\n" if your using an editbox
control to display the string. You might also need to check the multiline
checkbox in the properties of the control.

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.
 
Back
Top