I am new to C++. While I was learning the strtok()
function, I tried to cout
after execution of the function, but I can't understand why the cout
is not executing.
#include<iostream>
#include<cstring>
#include<climits>
#include<string>
#include<algorithm>
using namespace std;
int main() {
char s[100]="today is a rainy day";
char *ptr=strtok(s," ");
cout<<ptr<<endl;
while(ptr!=NULL){
ptr=strtok(NULL," ");
cout<<ptr<<endl;
}
cout<<"Hello";
return 0;
}
Please help me understand where this goes wrong.