Re: String Character Conversion



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.


.



Relevant Pages

  • Re: String Character Conversion
    ... Where I want to search for the word "Needle" with two linefeeds. ... The newline characters *are* characters, ... The string as read is "Needle\n\n", but what the string really needs to ...
    (comp.lang.c)
  • Re: String Character Conversion
    ... Say I have a string read from a configuration file. ... Where I want to search for the word "Needle" with two linefeeds. ... hasn't converted the linefeeds into characters? ...
    (comp.lang.c)
  • Re: String Character Conversion
    ... Say I have a string read from a configuration file. ... Where I want to search for the word "Needle" with two linefeeds. ... The newline characters *are* characters, ...
    (comp.lang.c)
  • Re: How to convert Infix notation to postfix notation
    ... If this is for an error message, why isn't it using stderr for its output? ... array of 15 characters, and you call this function with the limit 15 on ... Making sure that the only string I allocate and append to, ... because mulFactor in all versions must needs incorporate the functions ...
    (comp.lang.c)
  • Re: Prothon should not borrow Python strings!
    ... """It does not make sense to have a string without knowing what encoding ... same cul de sac as Python. ... Prothon_String_As_ASCII // raises error if there are high characters ... Python's split between byte strings and Unicode strings is ...
    (comp.lang.python)