Thread: std::string question. Containing HTML code?

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    18

    std::string question. Containing HTML code?

    Hi, I am trying to contain an HTML doctype declaration within an std string, but when I view the contents of the string during debugging the doctype is wrong, some characters are messed up.

    Here is an code:

    Code:
    string sDocType = "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">";
    How should I instantiate the string so that the doctype is stored correctly?

    Many thanks for any help.

  2. #2
    spaghetticode
    Guest
    You should mask the quotation marks within the string via \. The line shown shouldn't even pass the compiler.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    18
    Thanks for helping out, that worked a treat.

    and nice username BTW

  4. #4
    spaghetticode
    Guest
    Actually, I think it's rather boring. Plus it's a bit exaggerated, since I'm only a beginner trying to learn C++, so I'd rather be "hello_world.cpp". Was just the first thing that came into my mind... I'm not a good nicknamer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. obtaining the html code using C
    By hitesh123 in forum Windows Programming
    Replies: 2
    Last Post: 06-10-2010, 01:56 AM
  2. Please Help - C code creates dynamic HTML
    By Christie2008 in forum C Programming
    Replies: 19
    Last Post: 04-02-2008, 07:36 PM
  3. HTML/Javascript Getting by certain code?
    By two31d in forum Tech Board
    Replies: 4
    Last Post: 11-08-2005, 08:10 AM
  4. Code to HTML
    By IfYouSaySo in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-15-2005, 03:00 AM
  5. Code to HTML?
    By RetroGamer1991 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-19-2002, 12:47 PM