find space in string

#include <iostream>
#include <string>

int main() {
    std::string inputString;

    // Get input string from the user
    std::cout << "Enter a string: ";
    std::getline(std::cin, inputString);

    // Find and print the index of the first space in the string
    size_t spaceIndex = inputString.find(' ');
    if (spaceIndex != std::string::npos) {
        std::cout << "First space found at index: " << spaceIndex << std::endl;
    } else {
        std::cout << "No space found in the string." << std::endl;
    }

    return 0;
}