That is what ended up tooo ...on more step
I know it is a simple mistake but I can't see it ...
You know when somebodays brain stoped.....
this is the file ...
#include<iostream>
#include<string.h>
int main()
{
string str1;
int i=0;
int j=0;
int counterwords =1;
cout<< "Please input your text string... \n";
cin>> str1;
while (str1[i]<>0)
{
i++;
if (str1[i] == " ")
{
counterwords++;// how many words we have here
}
if (str1[i] <>( ' '|| ',' || ';' || '.' ||'!' || '?' ))
{
j++;// how many charactors that the lines have
}
}// while
int ave =0;
ave = j div counterwords ;// what is the avarage of the words in this line...
cout<< " the number of words that you have intered is :" << counterwords<<endl;
cout<< "the number of the char that you have is :"<< j<< endl;
cout<< " the avarage of the word lingth is :" << ave << endl;
return 0;
}
_____________
Please chick it up/
:p :p :p I am drank
Thnx:p
I ended up to get this ...
#include<iostream.h>
#include<string>
void main()
{
string str1;
int i=0;
int j=0;
int counterwords =1;
cout<< "Please input your text string... \n";
cin>> str1;
while (str1[i] != 0)
{
i++;
if (str1[i] == " ")
{
counterwords++; // how many words we have here
}
if (str1[i] != ( ' '|| ',' || ';' || '.' ||'!' || '?' ))
{
j++;// how many charactors that the lines have
}
}// while
int ave =0;
ave = j/ counterwords ;// what is the avarage of the words in this line...
cout<< " the number of words that you have intered is :" << counterwords<<endl;
cout<< "the number of the char that you have is :"<< j<< endl;
cout<< " the avarage of the word lingth is :" << ave << endl;
cout<< endl;
cout<< endl;
cout<< "take care";
//return 0;
}
___________________________
I ended up to get this error....
Look at this :
[NANO@****] (~) g++ counter.cpp -o counter
counter.cpp: In function `int main (...)':
counter.cpp: 16: ISO C++ forbids comparison between pointer and integer
[NANO@****] (~) vi counter.cpp
_______________
That was the message...
I know it is so stioped... but I gave up
:D new Drunker..... :D
Last Edition... with some mistakes
Actually this program is to count how many words do you have in the string str1 and what is the avarage of the words....
after I read alot about strings and after I got some ideas from here... I would like you to help me fixing the problem .....
I think it can't count more than one word....
Please take a look at the progam now....
#include<iostream.h>
#include<string>
int main()
{
string str1;
int j=0;
int counterwords =1;
cout<< "Please input your text string... \n";
cin>> str1;
cout<< "it is in \n";
string::iterator str1_ptr = str1.begin();
int i=0;
while (str1_ptr <= str1.end())'
{
i++; // increase one visit...
if (*str1_ptr == ' ')
{
counterwords++; // how many words we have here
}
// if (*str1_ptr != ( ' '|| ',' || ';' || '.' ||'!' || '?' ))
if (*str1_ptr != ','|| *str1_ptr != ' ')
{
j++;// how many charactors that the lines have
}
str1_ptr++;
}// while
int ave =0;
j--;// to shift j one because it has 1more char
ave = j/ counterwords ;// what is the avarage of the words in this line...
cout<< " the number of words that you have intered is :" << counterwords<<endl;
cout<< "the number of the char that you have is :"<< j<< endl;
cout<< " the avarage of the word lingth is :" << ave << endl;
cout<< endl;
cout<< "take care"<<endl;
cout<<" the program inter the loop for :"<<i << " times";
return 0;
}
______________
I will go to chick the resultes then I will past them...
Please read the last two Reply...
I just posted on them the latest ver. of my program and the resulte that I got out.... and I don't know why...
Please help me out....
thank you....