Unix/Linux Go Back    

Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Display quotes


Closed Linux or Unix Question    
Thread Tools Search this Thread Display Modes
Old Unix and Linux 10-07-2012
chercheur857 chercheur857 is offline
Join Date: Mar 2012
Last Activity: 16 December 2014, 10:19 AM EST
Posts: 98
Thanks: 49
Thanked 1 Time in 1 Post
Display quotes


Please how can display quotes with a C program:

fprintf(f," Hello "World"");

in the file i'd like to have Hello "World"

Thank you so much.
Sponsored Links
Old Unix and Linux 10-07-2012
JohnGraham JohnGraham is offline
Registered User
Join Date: Feb 2010
Last Activity: 9 May 2014, 6:02 PM EDT
Posts: 126
Thanks: 0
Thanked 31 Times in 29 Posts
Originally Posted by chercheur857 View Post

fprintf(f," Hello "World"");

When the compiler sees this, it sees " Hello "World"" as three things - a string " Hello ", the token World and an empty string, "". To get it to recognise the middle quotes as part of the string, as opposed to the end/start of the string, you need to escape them with the \ character (just like you use \n and the compiler recognizes you mean a newline, not the letter 'n'):

fprintf(f," Hello \"World\"");

The Following User Says Thank You to JohnGraham For This Useful Post:
chercheur857 (10-07-2012)
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove double quotes within double quotes - delimiter used is comma makn Shell Programming and Scripting 5 05-15-2012 04:54 AM
Having a terrible problem with quotes/single quotes! jondecker76 Shell Programming and Scripting 2 07-27-2011 04:22 AM
grep single quotes or double quotes george_vandelet UNIX for Dummies Questions & Answers 2 10-27-2010 11:23 AM
Single quotes and double quotes sol_nov Shell Programming and Scripting 5 09-16-2009 09:44 PM
Double quotes or single quotes when using ssh? password636 Shell Programming and Scripting 3 05-29-2008 08:52 PM

All times are GMT -4. The time now is 05:28 AM.