How to escape single quota in char * string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rogerwux
    New Member
    • May 2008
    • 1

    How to escape single quota in char * string

    Hi there,
    I got a char * pointer to some data and I was wondering how to replace
    single quota, any ideas ? thanks
  • arnaudk
    Contributor
    • Sep 2007
    • 425

    #2
    I guess you mean you have an array of characters and want to replace any single quotes " ' " in that array? If you're using C++, it would be much easier to put your data in a C++ string, then you can use its many easy and powerful search and replace functions. In C, iterate through the array until the terminating null, testing for single quotes at each step.

    Comment

    • Sick0Fant
      New Member
      • Feb 2008
      • 121

      #3
      use the ascii code for the single quote.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by Sick0Fant
        use the ascii code for the single quote.
        Please don't; if you run that thing on an EBCDIC machine it'll fail miserably.

        kind regards,

        Jos

        Comment

        • Sick0Fant
          New Member
          • Feb 2008
          • 121

          #5
          Originally posted by JosAH
          Please don't; if you run that thing on an EBCDIC machine it'll fail miserably.

          kind regards,

          Jos
          Yeah... in case you own a mainframe go ahead and adjust for that. Otherwise, you'll more than likely be fine. o_0

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by Sick0Fant
            Yeah... in case you own a mainframe go ahead and adjust for that. Otherwise, you'll more than likely be fine. o_0
            Murphy said it much better: "anything that can go wrong will go wrong". Always
            leave out magic numbers from your code.

            kind regards,

            Jos

            Comment

            Working...