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
Answer from Glenn Teitelbaum on Stack OverflowVideos
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
Use "\"" (backslash") for putting " in a string
Do I only use
#include <string>if a variable represents a string?
Yes.
Use #include <string> when you use a variable that has type std::string.
The code "text here", contrary to intuition, is not a std::string; it is a string literal, and a C-style string, and a const char[10] convertible to const char*. Welcome to C++ with its legacy oddities.
If you use the type std::string in your code then you should include the <string> header. There are also a few other types and functions in that header, but std::string is the most commonly used one.
However, you do not need to include this header just to use string literals, which are built into the core language.
As there are a lot of string manipulation functions, what are note-worthy?
Im a beginner in cpp. I have experimented and realised that I can use std::string and std::getline without the need of <string>. The <iostream> seems to take care of it. Is there any real need to use <string>?