Hello all, I'm having a lot of trouble with extracting individual words from an array of words. First I input a file into an array, and then I'm trying to extract each word into a seperate cstring, I can do it if the number of words is given, but if not then I'm drawing a blank. But, lets say that I know that maximum number of words is 25, what then?
this is what I have so far:
Code:
#include <iostream>
#include <fstream>
using namespace std;
const int SIZE = 81;
const int MAX_WORDS = 25;
int main()
{
ifstream inStream;
//ofstream outStream;
inStream.open("darwin.txt");
if ( inStream.fail() ) {
cout << "Input file opening for darwin.txt failed. Exiting...\n\n";
exit(-1);
}
char theWords[MAX_WORDS][SIZE];
int wordRow = 0;
int count = 0;
int i;
int numberOfWords=0;
char j;
char *pWord;
char word[SIZE/2][SIZE];
int c=0;
while ( inStream >> theWords[wordRow])
{
wordRow++;
}
............and here I'm drawing a blank
return 0;
should I test if the an element of theWords array is a blank space " ", but then how could I account for punctuation? I know I don't have much done this time, but any suggestions would be much appreciated,
thanks
axon