Hi i just registered on this forum, so , my problem is that i need to create a program that counts how many characters a user write also counting spaces , but i dont get how to count spaces.
Your question didn't quite point out if you're a beginner or not, so I'll assume your not. Here's a snippet, apply the headers and all necessary things
1 2 3 4 5 6 7 8
std::string str = "I am a string with spaces. Spaces are characters as well, note that";
int all_characters_including_spaces = str.length();
//equivalent to the length of the string
//int all_characters = std::distance(str.cbegin(), str.cend());
int total_number_of_spaces = std::count_if(str.cbegin(), str.cend(), [](char _ch)->bool { return _ch ==' '; });