Solved

removing double quotes from a CString

Posted on 1998-12-28
6
1,490 Views
Last Modified: 2008-01-16
Does anyone know how to add a double quotation mark to a CString literal. I have tried \" and it seems not to work for some reason.
0
Comment
Question by:Gareon
6 Comments
 

Author Comment

by:Gareon
ID: 1181176
I am using a CString containing special characters which I want to remove from CStrings in order to separate out only the words. The CString looks like this:
" ,.;:[]{}()*&%#@!~`'?\n\""

When I check against each char in the CString, the program removes everything but the double quotes, which it insists on tacking onto words.

0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1181177
CString str = "\"" ;

// str will contain a single character (the double quote)

I would suggest you find double quotes using the Find member function of CString

int nIndex = str.Find( '"' ) ; // single quote, double quote, single quote

My guess is you are confusing the single and double quoting mechanism.  Single quotes are used for char variables, double quotes for strings.

Your question is not clear, perhaps you want to explain more or post some code

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1181178
Just a guess.... When searching the CString for the double quote search for \" and not for "

If it works good, if not :-| (Maybe give some code where you try to find the string or somethin)

-Viktor
--Ivanov
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 86

Expert Comment

by:jkr
ID: 1181179
This is strange
CString str ( _T("text"));

str = CString(_T("\"")) + CString(_T("quoted "))+ str + CString(_T("\""));

should result in "quoted text", and str.Find( "\"") or str.Find( '\"') should both work... (and even the constructors shouldn't be necessary...)
0
 

Expert Comment

by:nbell
ID: 1181180
Gareon, it seems the common theme here is "it should work". Would you please post the source code so we can make it work.
0
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 50 total points
ID: 1181181
I'm guessing this will do the trick

" ,.;:[]{}()*&%#@!~`'?\n\"\x93\x94"

Cheers Greg
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question