see a class that has a string here is a function for that class that remove space.
some special i see in this function is that it calls itself even after printing last line that isCode:void clc::remove_spcae() { cout<<"string inputted by user is "<<eqn<<endl; int i(0); do { if(eqn[i]==' ') { for(int j=i+1;eqn[j]!='\0';j++) { if(eqn[j]==' ') cout<<""; else { if(eqn[j]=='\0') { eqn[i]=eqn[j]; break; } eqn[i]=eqn[j]; eqn[j]=' '; this->eatspcae(); } } } i++; } while(eqn[i]!='\0'); cout<<"newer string is "<<this->eqn<<endl; }
it should call irself from inside function not if it came outside do while loop.Code:cout<<"newer string is "<<this->eqn<<endl;
if it not do so then it will work correctly.
as well as it hangs just before end.
after running it twice my CPU usage is goes to70%(and not going down) which is usually 5 % to 15% are these things linked to each other.
thnk's to all answerer.




Reply With Quote