Thread: Unreconized escape character secquence

  1. #1
    Registered User
    Join Date
    Apr 2012
    Florida, Dade County, Homestrad, 33031

    Unreconized escape character secquence

    Thanks for all your help guys;
    I get an "Unrecognized escape character sequence" here,

     ifstream a_file ( "D:\ LotteryProgram / MegaMill" );   //Opens MegaMill for reading the file
       a_file >> str; //Reads one string from the file MegaMill
    and I don't understand it. Please explain why? . . . . therry

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Because you should escape your backslashes within a string literal, e.g.,
    ifstream a_file ( "D:\\ LotteryProgram / MegaMill" );
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Liverpool UK
    If you try to use a single backslash the compiler expects an escape character like \n newline etc. So as laserlight shows you have to add the extra oblique. As an example try outputting a quoted string and see what happens, eg show this including the quotes : "Hello World"
    Last edited by rogster001; 04-07-2012 at 04:38 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Escape sequences in c
    By linuxlover in forum C Programming
    Replies: 3
    Last Post: 11-03-2010, 02:39 PM
  2. Annoying Escape Character Squares in Notepad
    By firetheGlazer in forum A Brief History of
    Replies: 11
    Last Post: 07-18-2008, 02:17 AM
  3. Escape Key
    By mrafcho001 in forum Windows Programming
    Replies: 1
    Last Post: 11-10-2005, 04:51 PM
  4. Can you escape ...
    By Hammer in forum A Brief History of
    Replies: 11
    Last Post: 04-28-2005, 10:25 AM
  5. escape sequence
    By Unregistered in forum C Programming
    Replies: 8
    Last Post: 08-01-2002, 08:36 AM