I have this code :
int main(int argc, char * argv[])
{
int i;
printf("%d%s",argc,argv[1]);
return 0;
}
If I run this code as a.out a\=b=.I am using C-shell
Its output is “a=b=” is there any way that its output can be changed to “a\=b=“.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Update for edited question:
Enclose your command line argument in quotes:
The quotes prevent the shell from interpreting the command line argument in any way, so just this string is passed to your program. I use the
csh/bash..works with both.Alternatively, you can “escape” the
\with another one and skip the double quotes:Previous answer to original question:
Yes, use two
\:outputs:
Explanation:
\is an escape character used to indicate a special character sequence, so for instance\tindicates a tab. If you want to actually print\t, you need to “escape” this\with another\. See this example and output:which results in:
This is not unique to the
printf()function, nor really to C, may languages use the backslash to indicate “escape sequences” in strings.