Originally Posted by
jimblumberg
Without any of these features you're going to have problems controlling anything. Even a do/while or while() loop use some kind of logical operation. You need to show some code illustrating what you're trying to do and ask questions based on the code you provide.
Jim
All logical operators so far have been only == and != I should say.
Still working on the flow so the code below isn't polished yet.
Here is the code I have so far:
Code:
#include <iostream>
#include <cstring>
using namespace std;
int main() {
int x,y = 0,done = 1;
int Numwords = 0;
int set = 0;
char temp_input_line[80];
char current_word [80] = "";
do {
cin.getline(temp_input_line,79);
x=0; // Set beginning array count to 0
while (temp_input_line[x] != 13){ //Check for Return
while (temp_input_line[x] != ' '){ //Check for Space
current_word [y] = temp_input_line [x];
x++;
y++;
set = 1; //Set Flag that word started
} //End check for space
Numwords += set; //Increase word count
set = 0; //Reset word count flag
current_word [y + 1] = '\0'; //need to compare and set flag here if 'done' found.
y = 0;
done = strcmp("done",current_word); //Maybe need another 'while' loop here to set 'done' to 1 or 0 flag.
} //End check for Return
}while (done != 0);
cout << "Number of words is : " << Numwords << endl;
return 0;
}