Re: String Character Conversion
- From: Jayson Davis <eclecticboxers@xxxxxxxxx>
- Date: Fri, 30 Jun 2006 16:43:13 GMT
Eric Sosman wrote:
Jayson Davis wrote On 06/30/06 11:46,:
Say I have a string read from a configuration file.
searchfor <tab> Needle\n\n
Where I want to search for the word "Needle" with two linefeeds. Now when I read it from the file, it hasn't converted the linefeeds into characters. Is there a function to do that or do I need to write it myself?
Please explain what you mean by "it hasn't converted ..."
The newline characters *are* characters, and can be read and
written just like vowels and consonants.
Thanks for the reply. I'm taking a summer course in C and this is all a tad overwhelming having it shoved into such a short timespan.
The string as read is "Needle\n\n", but what the string really needs to be is "Needle\x0A0\x0A" in order for strstr() or strcmp() to work. In other words, the string is literal "\n" and not '\n'.
I've gone through the string.h functions and did Google searches for functions that would make replacement a little easier, but it would appear I'm going to have to construct something myself. I'm curious if there's a slick way to do it, or just trudge through one character at a time.
.
- Follow-Ups:
- Re: String Character Conversion
- From: Eric Sosman
- Re: String Character Conversion
- References:
- String Character Conversion
- From: Jayson Davis
- Re: String Character Conversion
- From: Eric Sosman
- String Character Conversion
- Prev by Date: Re: So what Standard are we working off?
- Next by Date: Re: Safe use of unions
- Previous by thread: Re: String Character Conversion
- Next by thread: Re: String Character Conversion
- Index(es):
Relevant Pages
|