944,116 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4048
  • C++ RSS
Dec 19th, 2004
0

ANSI string problem

Expand Post »
I am used to using:

C++ Syntax (Toggle Plain Text)
  1. char *str;

to make a string but recently have changed to using the ANSI string class as its a lot more powerful and easier to use... BUT i have a problem!

when I have encountered a string which conatins a " character I have used the following for a c-style string

C++ Syntax (Toggle Plain Text)
  1. char *str = 'quote = "hello"';
Which means it will contain "quote = "hello""
However i have a line of code which is

C++ Syntax (Toggle Plain Text)
  1. string str = '<tr><td><img src="log_error.bmp"></td><td><b>';
but it gives an error. It seems like the new ANSI string wont accept the ' character. Does anyone know how i can write that string to include the " characters around the bmp filename?
Similar Threads
Reputation Points: 16
Solved Threads: 6
Posting Pro in Training
1o0oBhP is offline Offline
445 posts
since Dec 2004
Dec 19th, 2004
0

Re: ANSI string problem

You inspired me to add one more item to my code snippet on std::string ...
[php] // use \" for embedded double quotes
string s1 = "<tr><td><img src=\"log_error.bmp\"></td><td><b>";
cout << s1 << endl << endl;
[/php]
Moderator
Reputation Points: 1333
Solved Threads: 1404
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Dec 19th, 2004
0

Re: ANSI string problem

ahh thanks. This means i could add a snippet too!! i have a logging system that makes a html file with icons for each type of entry (its normal, its a warning, its an error ect...) its all tabulated as well
Reputation Points: 16
Solved Threads: 6
Posting Pro in Training
1o0oBhP is offline Offline
445 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Help w/ dynamic list funtction definitions
Next Thread in C++ Forum Timeline: Playing around with std::string





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC