stringlengthfrompointer
#include <cstring>
#include <iostream>
//http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/
using namespace std;
// this takes a pointer to a char array and the length of array as params
int strlength (char *strx, int size)
{
int count;
for (int x=size-1; x>=0; x--)
{
count++;
if(isspace(strx[x]))
{
count--;
}
return count;
}
}
/*
int main(){
//define array
const int length =30;
char name[length];
//prompt for string
cout <<"enter a string\n";
cin.getline(name, length);
//pass its length and the array as params to function
cout << "the number of characters is " <<strlength(name,strlen(name));
cin.ignore();
}
*/