#include <iostream>
int count_white_spaces_in_string(const char* s) {
int white_spaces = 0;
const char* p = s;
while (*p != '\0') {
if (*p == ' ' || *p == '\n' || *p == '\t' || *p == '\r') {
white_spaces++;
}
p++;
}
return white_spaces;
}
int main() {
const char* s = "C++ \r Programming \n Developer \t ";
std::cout << "White spaces = " << count_white_spaces_in_string(s) << std::endl;
}
/*
run:
White spaces = 10
*/