I'm an aspiring programmer. I know I have a lot to learn, that’s why I’m starting to solve some problem my co-worker asked me.
Here's what i know, these counts the length of the string:
#include<iostream.h>
#include<string.h>
#include<stdio.h>
void main()
{
char str[80];
cout << "Count the length of the string" << endl;
cout << "Enter string: " << endl; gets(str);
cout << "The length is: " << strlen(str) << endl;
}
But what if I want to count by words not by length, what should I do?
Please give me advice, or tips, or reference books about this subject. Thanks in advance.
Here's what i know, these counts the length of the string:
#include<iostream.h>
#include<string.h>
#include<stdio.h>
void main()
{
char str[80];
cout << "Count the length of the string" << endl;
cout << "Enter string: " << endl; gets(str);
cout << "The length is: " << strlen(str) << endl;
}
But what if I want to count by words not by length, what should I do?
Please give me advice, or tips, or reference books about this subject. Thanks in advance.