Include double-quote (") in C-string
c, string
Solution
use the backslash: `"\""` is a string containing `"`
like this:
char str[67] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'-_\"";
added one for the implicit '\0' at the end (and put in the missing vV) - this could also be:
char str[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'-_\"";
and let the compiler count for you - then you can get the count with `sizeof(str)`;
How does it add up to 67?
a-z 26
A-Z 26
0-9 10
'-_" 4
'\0' 1
---
67
Problem
I would like a to define a variable string in C that contains the following set of characters: `a-zA-Z0-9'-_”`. Therefore I would do it like this: ``` char str[64] = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789'-_"" ``` As you can see the problem is at the end with `"` character. Question 1: How can I work around that? Question 2: Is there a better way than my way to define a string like that? PS: I didn't really know how to title my question, so if you got a better one, please edit it.