Looking for spaces in a string of chars.
I am trying to to get this program to find spaces in a
string of characters and display the count.
I am not sure of my codes and the error that I got seems
a little strange. Can anyone look at my codes and give me
some pointers.
Thank you
My os is VC++ ver. 6.0, I have a desktop using win 2k.
=================
My codes and the returned errors.
+++++++++++++++++++++++++++
#include <iostream>
#include <cstring>
using namespace std;
// not used --->char locate_blank(char *);
char line[] = "This is a string test. It contains two sentence.";
int main()
{
int count;
cout << "The original sentence is : " << line;
for (count = 0; line[count]= '\0'; count++)
{
if (line[count] == ' ')
{
line[count+1] = ' ';
break;
}
return count;
}
cout << "This sentence contains" << count(line) << "blanks";
}
/* Error list
------Configuration: findBlanks#2 - Win32 Debug-------
Compiling...
findBlanks#2.cpp
C:\Documents\Desktop\findBlanks#2.cpp(23) : error C2064: term does not evaluate to a function
Error executing cl.exe.
findBlanks#2.obj - 1 error(s), 0 warning(s)