Sign ' is the same as \' ?
-
Hello everyone, I am surprised to see that the value of sign ' is the same as \'. So, there is no need to add sign \ before sign '? In my past knowledge of sign ', we always need to add sign \ before sign '. Any comments? Here is my simple program to test.
int main (int argc, char** argv) { char* p1 = "Hello \'World\'"; char* p2 = "Hello 'World'"; int result = 0; result = strcmp(p1, p2); return 0; }
thanks in advance, George -
Hello everyone, I am surprised to see that the value of sign ' is the same as \'. So, there is no need to add sign \ before sign '? In my past knowledge of sign ', we always need to add sign \ before sign '. Any comments? Here is my simple program to test.
int main (int argc, char** argv) { char* p1 = "Hello \'World\'"; char* p2 = "Hello 'World'"; int result = 0; result = strcmp(p1, p2); return 0; }
thanks in advance, GeorgeMy friend, is quite obvious that
'
is different from\'
:-D (just kidding). Talking a bit seriously, you need such an escape sequence (that is symbol\'
) in circumstances like the following:char c = '\'';
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
My friend, is quite obvious that
'
is different from\'
:-D (just kidding). Talking a bit seriously, you need such an escape sequence (that is symbol\'
) in circumstances like the following:char c = '\'';
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
Hi CPallini, Actually I am also confused when I tried that, "Hello 'World'" is the same as "Hello \'World\'". I have also tried your sample. Now I am more confused... 1. What is the rule when we should use \' or single ' ? 2. When there is no differences between \' and '? (like my Hello 'World' sample) regards, George
-
Hi CPallini, Actually I am also confused when I tried that, "Hello 'World'" is the same as "Hello \'World\'". I have also tried your sample. Now I am more confused... 1. What is the rule when we should use \' or single ' ? 2. When there is no differences between \' and '? (like my Hello 'World' sample) regards, George
-
Hi CPallini, Actually I am also confused when I tried that, "Hello 'World'" is the same as "Hello \'World\'". I have also tried your sample. Now I am more confused... 1. What is the rule when we should use \' or single ' ? 2. When there is no differences between \' and '? (like my Hello 'World' sample) regards, George
as
C
Pallini stated, you need to use\'
only when the compiler can get confused. technically,\'
is the same ascii code as the character'
. just same as\"
is the same ascii code as the character"
. so, in brief, ben you use'
in a string (so, rounded with"
s), you don't need to use the escapment char (\
). when you use"
as a single char, no need either to use\
. some examples:"Hello \'World\'"
is the same as"Hello 'World'"
."Hello **"**World""
is forbidden because the second"
char is understood as the end of the string. here, you MUST write:"Hello **\"**World**\"**"
'"'
is the ascii code of the"
character.'**'**'
is forbidden. here again, the second'
char is understood as the end of the character specification. You MUST write:'**\'**'
. get it now ? subsidiary question: please, for god' sake, in what school level are you, and how old are you ? i'm not judging you, i'm questionning myself.
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Hi. You use single ' inside a string delimited by " characters i.e.
char* p2 = "Hello 'World'";
You use the \' when iusing it as a single character that need to be quoted within ' characters i.e.char p1 = '\'';
Habetis bona deum
Good reply, thanks DoomedOne! regards, George
-
as
C
Pallini stated, you need to use\'
only when the compiler can get confused. technically,\'
is the same ascii code as the character'
. just same as\"
is the same ascii code as the character"
. so, in brief, ben you use'
in a string (so, rounded with"
s), you don't need to use the escapment char (\
). when you use"
as a single char, no need either to use\
. some examples:"Hello \'World\'"
is the same as"Hello 'World'"
."Hello **"**World""
is forbidden because the second"
char is understood as the end of the string. here, you MUST write:"Hello **\"**World**\"**"
'"'
is the ascii code of the"
character.'**'**'
is forbidden. here again, the second'
char is understood as the end of the character specification. You MUST write:'**\'**'
. get it now ? subsidiary question: please, for god' sake, in what school level are you, and how old are you ? i'm not judging you, i'm questionning myself.
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
Cool toxcct! I must save your reply to somewhere. :-) regards, George