473,320 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

\' issue

I'm fairly new to c++, but I'm running across a problem that I can't
seem to resolve.

Whenever I add the character literal \' (ie single quote) to a str ing
I get a runtime error. It compiles just fine, but errors at runtime.

for example:

string s;
s = "Hello, I\'m confused";

compiles but gives me a runtime error.

I'm developing using VC++ in Visual Studio 2005.

Any help is appreciated.

M Kulangara

Jan 25 '07 #1
5 1319
Ru********@gmail.com wrote:
I'm fairly new to c++, but I'm running across a problem that I can't
seem to resolve.

Whenever I add the character literal \' (ie single quote) to a str ing
I get a runtime error. It compiles just fine, but errors at runtime.

for example:

string s;
s = "Hello, I\'m confused";

compiles but gives me a runtime error.

I'm developing using VC++ in Visual Studio 2005.
This is covered by the FAQ 5.8.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 25 '07 #2
Ru********@gmail.com wrote:
I'm fairly new to c++, but I'm running across a problem that I can't
seem to resolve.

Whenever I add the character literal \' (ie single quote) to a str ing
I get a runtime error. It compiles just fine, but errors at runtime.

for example:

string s;
s = "Hello, I\'m confused";

compiles but gives me a runtime error.

You have an error on line 42 of your program.

Victor referred you to FAQ 5.8, which essentially says "You didn't give
us enough info".

What errors are you getting? What results were you expecting? Where is
a complete, compilable example that exhibits the behavior that you are
asking about?
Jan 25 '07 #3
Thanks for the responses.... this string was passed to sql server. Of
course signlequotes must be doubled in this case. Changed and it is
now fixed.

Regards,
M Kulangara

On Jan 25, 11:53 am, red floyd <no.s...@here.dudewrote:
Rutgers...@gmail.com wrote:
I'm fairly new to c++, but I'm running across a problem that I can't
seem to resolve.
Whenever I add the character literal \' (ie single quote) to a str ing
I get a runtime error. It compiles just fine, but errors at runtime.
for example:
string s;
s = "Hello, I\'m confused";
compiles but gives me a runtime error.You have an error on line 42 of your program.

Victor referred you to FAQ 5.8, which essentially says "You didn't give
us enough info".

What errors are you getting? What results were you expecting? Where is
a complete, compilable example that exhibits the behavior that you are
asking about?
Jan 25 '07 #4
Ru********@gmail.com wrote:
>Thanks for the responses.... this string was passed to sql server. Of
course signlequotes must be doubled in this case. Changed and it is
now fixed.
I think that the reason you got an error at run time is that that's
when the string constant is evaluated. And in the evaluation, it hit
"\'". The backslash is the escape character, so it looks at the next
character to figure out what to do. But backslash-single quote is not
an escape sequence it knows about, so it complains.

Single quote doesn't need to be escaped.

--
Tim Slattery
Sl********@bls.gov
http://members.cox.net/slatteryt
Jan 25 '07 #5
On Jan 26, 10:12 am, Tim Slattery <Slatter...@bls.govwrote:
>I think that the reason you got an error at run time is that that's
when the string constant is evaluated. And in the evaluation, it hit
"\'". The backslash is the escape character, so it looks at the next
character to figure out what to do. But backslash-single quote is not
an escape sequence it knows about, so it complains.
Escape codes in string literals are processed at compile time.

Since the compiler didn't say anything, probably it just treated the
sequence as an unescaped quote mark.

The actual error was caused by something else, as described
by the OP in the post which you replied to (ie. he was passing
it to a third party API which was not expecting it).

Jan 25 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
7
by: George Hester | last post by:
Please take a look at this google artcle: http://groups.google.com/groups?hl=en&lr=&frame=right&th=55d6f4b50f5f9382&seekm=411f370d%241%40olaf.komtel.net#link9 The op was having trouble with...
2
by: Anthony Cuttitta Jr. | last post by:
We have an application that outputs several different graphs from data downloaded from our AS400. The application has worked without (this) issue for several months now, but just recently, the...
0
by: Kevin Spencer | last post by:
Hi all, I am working on a service that uploads METAR weather information to the National Weather Service FTP site. The service I'm authoring is hosted on a Windows 200 server, and the NWS FTP...
2
by: Ben Rush | last post by:
Hello World, Okay, I have spent the day browsing the newsgroups and reading up on article after article concerning ViewState corruption and so forth, and I have a couple questions. We...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
0
by: Charles Leonard | last post by:
I am having yet another issue with Windows Server 2003. This time, the web service (a file import web service) appears to run except for one odd message: "ActiveX component can't create object". ...
4
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
1
by: AlekseyUS | last post by:
Hi, I'm a little stuck, I basically need to copy all the information within a specific file in Temp and append it to a file in another location. I'm not having any problems with smaller size...
13
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.