473,323 Members | 1,589 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,323 software developers and data experts.

String includes RETURN KEY

hi, all.

Here is a stupid question.

I have three string
string str1 =" test1 ";
string str2 =" test21\ntest22\ntest23"; (\n means return key)
string str3 =" test3 ";
I write them to a file(test.txt) by using Stream.write();
I open the file:
it is:
test1
test21
test22
test23
test3
when I read test.txtby using Stream.read(), I can not restore it again.I got
5 string.
indeed, It should three string?

What should I do?

Thanks



Jul 21 '05 #1
5 1142
Can you provide more code. Streams work on bytes and there is no concept of
"5 string" since you are simply requesting the number of bytes. Are you
actually using a StreamReader or something?

"jeff" <je**@discussions.microsoft.com> wrote in message
news:17**********************************@microsof t.com...
hi, all.

Here is a stupid question.

I have three string
string str1 =" test1 ";
string str2 =" test21\ntest22\ntest23"; (\n means return key)
string str3 =" test3 ";
I write them to a file(test.txt) by using Stream.write();
I open the file:
it is:
test1
test21
test22
test23
test3
when I read test.txtby using Stream.read(), I can not restore it again.I got 5 string.
indeed, It should three string?

What should I do?

Thanks


Jul 21 '05 #2


"jeff" wrote:
hi, all.

Here is a stupid question.

I have three string
string str1 =" test1 ";
string str2 =" test21\ntest22\ntest23"; (\n means return key)
string str3 =" test3 ";
I write them to a file(test.txt) by using Stream.write();
I open the file:
it is:
test1
test21
test22
test23
test3
when I read test.txtby using Stream.read(), I can not restore it again.I got
5 string.
indeed, It should three string?

What should I do?

Thanks


Jul 21 '05 #3

try using the "@" literal string character in front of str2.
I did not try it but its an idea.

"jeff" wrote:
hi, all.

Here is a stupid question.

I have three string
string str1 =" test1 ";
string str2 =" test21\ntest22\ntest23"; (\n means return key)
string str3 =" test3 ";
I write them to a file(test.txt) by using Stream.write();
I open the file:
it is:
test1
test21
test22
test23
test3
when I read test.txtby using Stream.read(), I can not restore it again.I got
5 string.
indeed, It should three string?

What should I do?

Thanks


Jul 21 '05 #4
\n *is* the end of a line and is working correctly.

How can you want some of your ends of lines not to be ends of lines?

But if what you mean is that you want to preserve the strings, I suppose you
could convert every end of line mark to something else before writing the
string out, and undo the conversion after reading it in again.
"jeff" <je**@discussions.microsoft.com> wrote in message
news:17**********************************@microsof t.com...
hi, all.

Here is a stupid question.

I have three string
string str1 =" test1 ";
string str2 =" test21\ntest22\ntest23"; (\n means return key)
string str3 =" test3 ";
I write them to a file(test.txt) by using Stream.write();
I open the file:
it is:
test1
test21
test22
test23
test3
when I read test.txtby using Stream.read(), I can not restore it again.I
got
5 string.
indeed, It should three string?

What should I do?

Thanks


Jul 21 '05 #5
if you want new line Use :
"\r\n" - new line in windows
( '\n' = new line in Linux , '\r' = new line in Mac)
If you what '\n' in the file Use "\\n"

"jeff" <je**@discussions.microsoft.com> wrote in message
news:17**********************************@microsof t.com...
hi, all.

Here is a stupid question.

I have three string
string str1 =" test1 ";
string str2 =" test21\ntest22\ntest23"; (\n means return key)
string str3 =" test3 ";
I write them to a file(test.txt) by using Stream.write();
I open the file:
it is:
test1
test21
test22
test23
test3
when I read test.txtby using Stream.read(), I can not restore it again.I
got
5 string.
indeed, It should three string?

What should I do?

Thanks


Jul 21 '05 #6

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

Similar topics

13
by: usgog | last post by:
I need to implement a function to return True/false whether String A contains String B. For example, String A = "This is a test"; String B = "is is". So it will return TRUE if String A includes two...
28
by: David Rubin | last post by:
I looked on google for an answer, but I didn't find anything short of using boost which sufficiently answers my question: what is a good way of doing string tokenization (note: I cannot use boost)....
97
by: s | last post by:
Can I do this: #define MYSTRING "ABC" .. .. .. char mychar = MYSTRING; .. .. ..
29
by: zoro | last post by:
Hi, I am new to C#, coming from Delphi. In Delphi, I am using a 3rd party string handling library that includes some very useful string functions, in particular I'm interested in BEFORE (return...
6
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file =...
16
by: BBM | last post by:
This is so bizarre I hesitate to post it, but I need to get this working. My code looks like this... Private Const cmdTestResourcesSel = "SELECT * FROM TResources" & _ " WHERE Scenario =...
6
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
33
by: Jordan Tiona | last post by:
How can I make one of these? I'm trying to get my program to store a string into a variable, but it only stores one line. -- "No eye has seen, no ear has heard, no mind can conceive what God...
4
by: VMI | last post by:
How can I split a string that looks like this: John, Doe, 37282, box 2, 10001, "My description, very important", X, Home If I use String.Split(), it'll split the string that's between the...
94
by: smnoff | last post by:
I have searched the internet for malloc and dynamic malloc; however, I still don't know or readily see what is general way to allocate memory to char * variable that I want to assign the substring...
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...
0
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...
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: 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...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.