Reputation: 43
I am trying to print a parenthesis using: printf("\)"); However, it is giving me the following warning: warning: unknown escape sequence '\)'
I can't seem to find a clear explanation anywhere on how to fix this. I realize it's just a warning, but since it's still treating that as a parenthesis it's throwing off all my other parentheses and giving me errors so that the code does not compile.
EDIT: Treating it as a regular character and just saying printf(")") is not working. It's still mismatching all the parentheses and I have gone through multiple times to make sure I'm not actually missing any.
Upvotes: 2
Views: 28236
Reputation: 1
Hope this helps.
Using variables seems to be a viable solution using my compiler.
#include <stdio.h>
int main() {
char var = ')';
printf("Hello, World!\n");
printf("Success :%c",var); //As you can see this is one way to go about the problem
return 0;
}
Upvotes: 0
Reputation: 575
just write parenthesis in double quote " " ,because parenthesis is not a escape character .
try this :
#include<stdio.h>
int main(){
printf( "( )" ); // print parenthesis here
}
Upvotes: 0
Reputation: 126
try this:
#include <stdio.h>
int main()
{
printf("Printing quotation mark \")\" ");
}
you need to add an escape character to get the quote to print which in this case is \"
This will result in Printing quotation mark ")"
Upvotes: 2
Reputation: 15320
The warning is coming from the C compiler. It is telling you that \
is not a known escape sequence in C. You need to double-escape the slash, like so: \\
Edit: if you just want to print the parenthesis, i.e. the )
then drop the slash altogether and use:
printf(")");
Upvotes: 4