avgwordlengthfrompointer

#include <iostream>

#include <string>

using namespace std;

 

//http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/

/*

int main()

{

int i, numspaces;

char nextChar;

string msg;

numspaces=1;

cout << "Type in a string\n";

getline(cin, msg);

// checks each character in the string

for (i=0; i<int(msg.length()); i++)

{

nextChar = msg.at(i); // gets a character

if (isspace(msg[i]))

numspaces++;

}

cout << "\nIn this string there are about " << (int(msg.length()) - (numspaces-1))/numspaces << " letters in each word.";

cin.ignore();

return 0;

}*/

Popular posts from this blog

ch11 review silberschatz operating systems concepts essentials 2nd ed