0

i need to put many symbols in one array of char.

This is my code, I have problem with the single quote symbol, " ' " :

int main()
{
    int i, j;
    int a;
    char alph[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9','.',',',':','?','=','-','(',')','"',''','/','%','@','!'};
}
mantal
  • 1,093
  • 1
  • 20
  • 38
user3121134
  • 93
  • 4
  • 13

2 Answers2

3

You can escape the quote with a backslash, i.e. '\''

downhillFromHere
  • 1,967
  • 11
  • 11
1

To represent ' as a character, you must escape it. In C you do this by using \ : char c = '\'' You don't need to escape ' when using it inside a string (but inside string you need to escape ").

mantal
  • 1,093
  • 1
  • 20
  • 38
  • Characters like " **must** be escape using \ is not correct. "The double-quote " and question-mark ? are representable either by themselves or by the escape sequences \" and \?," C11dr §6.4.4.4 4 `'"'` is OK. – chux - Reinstate Monica Aug 29 '14 at 14:18
  • You must escape the `"` if it's in a double-quote string. You must escape the `'` if it's in a single-quote string (character). You don't need to escape `'"'` or `"don't"`. – hymie Aug 29 '14 at 14:34
  • @hymie Tanks, I forgot this case. I edited my answer. – mantal Aug 29 '14 at 14:48