How to put quotes in fprintf statement

This is a discussion on How to put quotes in fprintf statement within the C Programming forums, part of the General Programming Boards category; I am writing text to an ascii file. I want the text to look like... "John", "Doe" I have two ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    10

    How to put quotes in fprintf statement

    I am writing text to an ascii file.

    I want the text to look like...

    "John", "Doe"

    I have two variables, fName and lName

    how to write my fprintf() statement so I get the quotes in my output file.

    Thanks.

    mashley.
    Go Angels!
    Go Lakers!
    Go Trojans!
    Go Stock Market!

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    You can do a backslash-quote to output a quote in your fprintf().

    fprintf(fp,"\"%s\" \"%s\"\n",fName,lName);

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    10
    Thank you!
    Go Angels!
    Go Lakers!
    Go Trojans!
    Go Stock Market!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stripping quotes from a string
    By -W0kk3L- in forum C Programming
    Replies: 3
    Last Post: 03-15-2006, 01:03 PM
  2. The great struggle for random quotes!
    By Jeremy G in forum Game Programming
    Replies: 2
    Last Post: 01-26-2003, 01:28 PM
  3. explain this loop statement?
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 05-05-2002, 03:46 AM
  4. formatted printing with fprintf
    By lambs4 in forum C Programming
    Replies: 5
    Last Post: 11-20-2001, 09:04 AM
  5. check my code ( if statement, file existance )
    By Shadow in forum C Programming
    Replies: 1
    Last Post: 10-04-2001, 12:13 PM

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