I want to assign ' to a character but it keeps giving me error any help?
void main()
{
char c = ''';
}
Special characters like ' or \\ must be escaped with a backslash in these situations. In this particular case you got an error because the compiler thinks you opened and closed a null character with the first two '' and then opened another character without closing it with the third one.
\\'
represents Single quotation mark in C
It is a standard escape sequence
Every time you want to assign '
, just need to assign \\'
Use escape sequence:
char c = '\'';
Also, a double quotation mark is written as '\\"' in C.
PS: No void main()
, it should be int main(void)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.