Hello, I'm simply trying to keep track of how many times a space is encounteed in a string and then print the number of times to the console. Can someone please examine and give me a tip on what is wrong? Thank you!
#include <iostream>
using namespace std;
int main()
{
int count = 0;
// char newphrase[1024];
char phrase[1024];
cout << "enter phrase" << endl;
cin >> phrase;
int b = strlen(phrase);
for(int i = 0; i <= b; i++)
{
if(phrase[i] == ' ')
{
count++;
}
/*
{
strcpy_s(phrase, newphrase);
}
*/
}
cout << count << endl;
return count;
}