0

Can someone fix it ?

https://code.sololearn.com/c4lm59wRMmN6/?ref=app It's just a simple code that is writing each word on a separate line ... thanks!

26th Mar 2018, 7:43 AM
Oprea Radu
Oprea Radu - avatar
2 odpowiedzi
+ 2
Here : #include <iostream> #include <cstring> using namespace std; int main() { char s[101], *p; int wordcount = 0; // Use getline. gets is unsafe. cin.getline(s,101); // strtok separates string to words. p = strtok(s," "); while(p!=NULL) { cout<<p<<endl; wordcount++; p = strtok(NULL," "); } cout<<"Number of Words : " <<wordcount; }
26th Mar 2018, 7:52 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
Thanks a lot !
26th Mar 2018, 8:15 AM
Oprea Radu
Oprea Radu - avatar