470,810 Members | 1,173 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

Help with end-of-line string characters

I have this following code:

x= tempStr.IndexOf((char)13, 0);

The string tempSTR = "
Heading"

Notice that their is a Carriage Return and/or line feed before the
stirng value of "heading?" What I was wanting to do with this code is
for the variable x to equal to location of the first carriage
return/line feed/new line caracter (ASCII 13 or 10 values). But it
seems that when I run this the value of x= 9 instead of 1 why is this?

Bascially I am porting a VBA program into a C# program for a word
automation application I wrote. In VBA this is what I had for this
function:

x = InStr(1, tempStr, chr(13))

In VBA x = 1 not 9. Does anyone know of a whay to make the c#
expression equal 1 instead of 9?

Feb 9 '06 #1
3 4379
mr********@gmail.com wrote:
I have this following code:

x= tempStr.IndexOf((char)13, 0);

The string tempSTR = "
Heading"

Notice that their is a Carriage Return and/or line feed before the
stirng value of "heading?" What I was wanting to do with this code is
for the variable x to equal to location of the first carriage
return/line feed/new line caracter (ASCII 13 or 10 values). But it
seems that when I run this the value of x= 9 instead of 1 why is this?

Bascially I am porting a VBA program into a C# program for a word
automation application I wrote. In VBA this is what I had for this
function:

x = InStr(1, tempStr, chr(13))

In VBA x = 1 not 9. Does anyone know of a whay to make the c#
expression equal 1 instead of 9?


Why are you asking this in comp.lang.*c*?
--
==============
*Not a pedant*
==============
Feb 9 '06 #2
mr********@gmail.com wrote:

I have this following code:

x= tempStr.IndexOf((char)13, 0);

The string tempSTR = "
Heading"

Notice that their is a Carriage Return and/or line feed before the
stirng value of "heading?" What I was wanting to do with this code is
for the variable x to equal to location of the first carriage
return/line feed/new line caracter (ASCII 13 or 10 values). But it
seems that when I run this the value of x= 9 instead of 1 why is this?


/* BEGIN new.c */

#include <stdio.h>
#include <string.h>

int main(void)
{
char *tempSTR = "\nHeading";
char *ptr;

ptr = strchr(tempSTR, '\n');
if (ptr != NULL) {
printf("\ntempSTR[%d] is a newline character.\n",
(int)(ptr - tempSTR));
}
return 0;
}

/* END new.c */
--
pete
Feb 9 '06 #3
In article <11**********************@g47g2000cwa.googlegroups .com>,
<mr********@gmail.com> wrote:
I have this following code:

x= tempStr.IndexOf((char)13, 0);

The string tempSTR = "
Heading"

Notice that their is a Carriage Return and/or line feed before the
stirng value of "heading?" What I was wanting to do with this code is
for the variable x to equal to location of the first carriage
return/line feed/new line caracter (ASCII 13 or 10 values). But it
seems that when I run this the value of x= 9 instead of 1 why is this?

Bascially I am porting a VBA program into a C# program for a word
automation application I wrote. In VBA this is what I had for this
function:


Allow me to be the first to say this - and I say it from the deepness of my
heart, with all the kindness and love one has come to associate with the
helpful posts you get in this newsgroup:

Not portable. Can't discuss it here. Blah, blah, blah.

Feb 13 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Virginia Kirkendall | last post: by
1 post views Thread by Mike | last post: by
13 posts views Thread by Chua Wen Ching | last post: by
3 posts views Thread by Marek | last post: by
1 post views Thread by ucasesoftware | last post: by
1 post views Thread by mmuralha | last post: by
13 posts views Thread by Apostle | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.