473,396 Members | 2,090 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,396 software developers and data experts.

new Line escape Sequences not interpreted

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
Nov 17 '05 #1
2 954
"mattD" <ma***@nospam.nospam> wrote in message
news:11*************@corp.supernews.com...
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.

Nov 17 '05 #2

Frank Hickman [MVP] wrote:
"mattD" <ma***@nospam.nospam> wrote in message
news:11*************@corp.supernews.com...
<SNIP>


Thanks i changed the "\n" in the array to "\r\n" and it works.
Thanks,
mattD
Nov 17 '05 #3

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

Similar topics

8
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
6
by: Griff | last post by:
i'm using ActivePerl, version 5.6.1 My question is: How come print "\ " prints a backslash followed by a space
5
by: Mark | last post by:
I have a C# app that I am writing which is going to insert text into a table, which is then picked up by another program and emailed. On the text version of the email (when the user doesn't have...
6
by: Walter L. Preuninger II | last post by:
I need to convert escape sequences entered into my program to the actual code. For example, \r becomes 0x0d I have looked over the FAQ, and searched the web, with no results. Is there a...
3
by: Don | last post by:
I am building a string from a combination of hardcoded string literals and user input (via textbox). I know about using @"c:\temp\filename.txt" to ignore escape sequences. Now let's say I have a...
3
by: Herb Finkel | last post by:
The following code is fairly simple to capture command line arguments: using System; namespace ConsoleApplication1 { class Class1 { static void Main(string args) { string first = args;
5
by: nummertolv | last post by:
Hi, My application is receiving strings, representing windows paths, from an external source. When using these paths, by for instance printing them using str() (print path), the backslashes are...
10
by: hanaa | last post by:
Hello there. $str="This is \na ball"; echo $str; Is there a way i can make the text to be as is, without expanding the escape sequences. I know that single quoted strings do not expand escape...
5
by: John Ztwin | last post by:
Hello, I have a file that contains ordinary text and some special charaters in Unicode escape sequences (\uxxxx). When I read the file using e.g. StreamReader Unicode escape sequences are not...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.