How do I refer to a "
My program keeps crashing because I am searching for the " character in a string and I dont know how to reference it properly. Ive tried ''"'',''""'',''\"'' all to no avail. google game me no search results either.
I probably should stop, My doctor says I have the wrists of an 80-year old
I am not exactly sure *how* you are looking for the " character but this is a quick example.
-------
Andrew
PlaneShift - A MMORPG in development.
int main(){ char buffer[100]; sprintf(buffer, "This \"string\" has several \"''s in it\n"); for ( int x = 0; x < strlen(buffer); x++ ) if ( buffer[x] == ''"'' ) printf("Found \" at position %d\n", x ); return 0;}
-------
Andrew
PlaneShift - A MMORPG in development.
char doublequote = ''\"'';
or
char doublequote = 34;
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
or
char doublequote = 34;
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
Here's a similar question, but more complicated. Is there any way to pass the '"' character as part of a string? For example:
char string[] = "Is there a way to do "this"";
Obviously that won't work as it is, and doing something like '"'this'"' doesn't work either, also for obvious reasons. In the circumstance I've needed it, I've resorted to setting that character seperately after initialisation. I was wondering if there's a way to pass it inside a string.
[edited by - Nemesis2k2 on September 23, 2003 7:32:30 PM]
char string[] = "Is there a way to do "this"";
Obviously that won't work as it is, and doing something like '"'this'"' doesn't work either, also for obvious reasons. In the circumstance I've needed it, I've resorted to setting that character seperately after initialisation. I was wondering if there's a way to pass it inside a string.
[edited by - Nemesis2k2 on September 23, 2003 7:32:30 PM]
im trying to figure out how some who codes doesnt know this
but its been used in the posts above like 6 times
"this is a \"string\" with double quotes in it"
but its been used in the posts above like 6 times
"this is a \"string\" with double quotes in it"
*Tattoos "Dumbass" to forehead*
I can''t believe I forgot the escape character. Time to refresh myself on the basics I think.
I can''t believe I forgot the escape character. Time to refresh myself on the basics I think.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement