Thread: string format ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    Ottawa
    Posts
    18

    string format ...

    Hi All,
    A quick question,...


    I want my program to spit out the following line to a browser:


    <p><img src="myanim.gif" width="64" height="64"></p>


    How should I change this line?


    printf("<p><img src="myanim.gif" width="64" height="64"></p>");


    I think all of the quotes are confusing the machiene.

    Many Thanks

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    You need to 'escape' the quotes by preceding them with a '\' character.

    Quote Originally Posted by SkinneyEd
    Hi All,
    A quick question,...


    I want my program to spit out the following line to a browser:


    <p><img src="myanim.gif" width="64" height="64"></p>


    How should I change this line?


    printf("<p><img src=\"myanim.gif\" width=\"64\" height=\"64\"></p>");


    I think all of the quotes are confusing the machiene.

    Many Thanks
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Oct 2005
    Location
    Ottawa
    Posts
    18
    It worked!
    Thanks!

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Or, you can use single quote marks for the attribute values, which is much easier to type:

    printf("<p><img src='myanim.gif' width='64' height='64'></p>");

  5. #5
    Registered User
    Join Date
    Oct 2005
    Location
    Ottawa
    Posts
    18
    indeed
    many thanks!

  6. #6
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    why are you using printf in c++?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM