std::string question. Containing HTML code?

This is a discussion on std::string question. Containing HTML code? within the C++ Programming forums, part of the General Programming Boards category; Hi, I am trying to contain an HTML doctype declaration within an std string, but when I view the contents ...

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

    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
    language hopper dennis.cpp's Avatar
    Join Date
    Jan 2011
    Location
    Herborn, Hesse, Germany
    Posts
    197
    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
    14
    Thanks for helping out, that worked a treat.

    and nice username BTW

  4. #4
    language hopper dennis.cpp's Avatar
    Join Date
    Jan 2011
    Location
    Herborn, Hesse, Germany
    Posts
    197
    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, 02:56 AM
  2. Please Help - C code creates dynamic HTML
    By Christie2008 in forum C Programming
    Replies: 19
    Last Post: 04-02-2008, 08: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21