#include <iostream>
#include <string>

using namespace std;

int count_spaces(const string& str)
{
    int spaces = 0;
    for (char ch : str)
    {
        if (ch == ' ')
        {
            spaces++;
        }
    }
    return spaces;
}

int main()
{
    string quote = "Whenever you read a good book, ";
    quote += "it's like the author is right there, ";
    quote += "in the room, talking to you, ";
    quote += "which is why I don't like to read good books.";
    string citation = "-- Deep Thoughts, by Jack Handey";

    cout << "Number of spaces in quote: ";
    cout << count_spaces(quote) << endl;
    cout << "Number of spaces in citation: ";
    cout << count_spaces(citation) << endl;

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: