Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Barguast

Quotations in character strings

This topic is 5330 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I include quotation marks in a constant character string? For example:
printf (""abc"");
 
Will print out: "abc"

Share this post


Link to post
Share on other sites
Advertisement
Escape the double quotes inside the string by putting a backslash directly in front of them.

Edit: FIRST POST!!! Oh... crap.

[edited by - bobstevens on April 15, 2004 1:24:14 PM]

Share this post


Link to post
Share on other sites
use \"
printf("\"abc\"");  
edit: 2 replies while I wrote that

[edited by - Eriond on April 15, 2004 1:24:24 PM]

Share this post


Link to post
Share on other sites
Use a slash before the quotes you want to be output:

printf("\"abc\"");

OK, sorry, just kidding, I realize 3 people have already said that.

Just for interest sake, you can also do:

printf("%cabc%c", '"', '"'); // using quote characters


or

printf("%cabc%c", 0x22, 0x22); // using ASCII codes for the quote character





[edited by - BriTeg on April 15, 2004 1:36:07 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!