newline in string 
Author Message
 newline in string

Im initializing a character pointer like this
char* test = "some text"

Is there any way to insert a newline character.

EX:
char* test = "Some \n text"



Sun, 27 Feb 2005 22:13:01 GMT  
 newline in string


Quote:
>Im initializing a character pointer like this
>char* test = "some text"

>Is there any way to insert a newline character.

>EX:
>char* test = "Some \n text"

Yes, that's how you do it. But make it const char * instead of char *,
because you have no guarantee that string literals are in writeable
memory, and the compiler may not duplicate strings in memory if you use
the same string more than once.

--
Be seeing you.



Sun, 27 Feb 2005 22:35:25 GMT  
 newline in string
Maybe the problems in how im outputting it.
Im sending it to an edit box like this

SendDlgItemMessage(hDlg, IDC_EDIT_PREPEPTALK,
WM_SETTEXT  , 0, (LPARAM)test);

does the edit box ignore the \n character?

Quote:
>-----Original Message-----
>On Wed, 11 Sep 2002 07:13:01 -0700, "mike"


Quote:

>>Im initializing a character pointer like this
>>char* test = "some text"

>>Is there any way to insert a newline character.

>>EX:
>>char* test = "Some \n text"

>Yes, that's how you do it. But make it const char *
instead of char *,
>because you have no guarantee that string literals are
in writeable
>memory, and the compiler may not duplicate strings in
memory if you use
>the same string more than once.

>--
>Be seeing you.
>.



Sun, 27 Feb 2005 22:48:54 GMT  
 newline in string
Edit box expects "\r\n" sequence.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Maybe the problems in how im outputting it.
> Im sending it to an edit box like this

> SendDlgItemMessage(hDlg, IDC_EDIT_PREPEPTALK,
> WM_SETTEXT  , 0, (LPARAM)test);

> does the edit box ignore the \n character?

> >-----Original Message-----
> >On Wed, 11 Sep 2002 07:13:01 -0700, "mike"


> >>Im initializing a character pointer like this
> >>char* test = "some text"

> >>Is there any way to insert a newline character.

> >>EX:
> >>char* test = "Some \n text"

> >Yes, that's how you do it. But make it const char *
> instead of char *,
> >because you have no guarantee that string literals are
> in writeable
> >memory, and the compiler may not duplicate strings in
> memory if you use
> >the same string more than once.

> >--
> >Be seeing you.
> >.



Sun, 27 Feb 2005 23:52:24 GMT  
 newline in string
Quote:

>does the edit box ignore the \n character?

An editbox requires a CR/LF combination, like this:

"Some \r\n text"

Andy



Sun, 27 Feb 2005 23:10:52 GMT  
 newline in string
Also make sure the edit box is created with ES_MULTILINE style.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Maybe the problems in how im outputting it.
> Im sending it to an edit box like this

> SendDlgItemMessage(hDlg, IDC_EDIT_PREPEPTALK,
> WM_SETTEXT  , 0, (LPARAM)test);

> does the edit box ignore the \n character?

> >-----Original Message-----
> >On Wed, 11 Sep 2002 07:13:01 -0700, "mike"


> >>Im initializing a character pointer like this
> >>char* test = "some text"

> >>Is there any way to insert a newline character.

> >>EX:
> >>char* test = "Some \n text"

> >Yes, that's how you do it. But make it const char *
> instead of char *,
> >because you have no guarantee that string literals are
> in writeable
> >memory, and the compiler may not duplicate strings in
> memory if you use
> >the same string more than once.

> >--
> >Be seeing you.
> >.



Mon, 28 Feb 2005 00:02:27 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. stripping newlines from strings

2. newlines in string constants

3. Remove newlines from string

4. How do you get a newline in a textbox and string in C#

5. insert newlines into long string

6. string newline replace

7. length of strings w. newlines in them

8. building a string with newline characters

9. Adding a newline to a string

10. Newline in commandline string

11. formatting long strings using sprintf() without including tabs or newlines

12. Checking for newline in a stream - StreamReader.ReadLine() is totally useless

 

 
Powered by phpBB® Forum Software