string format ...

This is a discussion on string format ... within the C++ Programming forums, part of the General Programming Boards category; Hi All, A quick question,... I want my program to spit out the following line to a browser: <p><img src="myanim.gif" ...

  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,672
    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
    I used to be an adventurer like you... then I took an arrow to the knee.

  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,662
    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, 10:03 PM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 09:33 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 01:45 PM

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