Thread: Missing terminating character

  1. #1
    Registered User
    Join Date
    Mar 2016
    Posts
    203

    Missing terminating character

    Background: Palindrome checker that takes input string and removes any whitespaces and characters that are not alphabets or numbers. It then converts the resultant string to lowercase throughout using transform() and then reverses this string using rbegin(), rend() before doing palindrome checks

    Problem:
    code works fine except for removing the single apostrophe as seen in words like don't, can't

    Code: I am using Dev-C++ 5.11 and have tried turning off 'Complete Single Quotes' under 'Symbol Completion' in 'Editor Settings' but that doesn't help. I am getting "missing terminating ' character" error for the following code:
    Code:
    string str;
    str.erase(remove(str.begin(), str.end(), ' ' '), str.end());
    It seems the compiler expects the apostrophe characters in pairs. I am not posting the full code but just the bit relating to this particular issue.

    Any suggestions, as always, would be most welcome. Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Try
    Code:
    str.erase(remove(str.begin(), str.end(), '\''), str.end());
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2016
    Posts
    203
    Many thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. the null terminating character
    By yvan in forum C Programming
    Replies: 13
    Last Post: 03-08-2016, 02:00 PM
  2. Check terminating null character
    By Ducky in forum C++ Programming
    Replies: 2
    Last Post: 10-10-2010, 03:07 AM
  3. error: missing terminating " character
    By nasim751 in forum C Programming
    Replies: 2
    Last Post: 04-17-2008, 01:50 AM
  4. terminating a while loop with a character
    By just_learning in forum C Programming
    Replies: 3
    Last Post: 04-13-2007, 05:22 AM
  5. Null terminating a character pointer?
    By INFERNO2K in forum C++ Programming
    Replies: 9
    Last Post: 11-28-2005, 08:52 AM

Tags for this Thread