Could you tell me why in the following code it works fine if I take the 'while' loop out but as it stands it outputs all the parts of 'today' that it has parsed out and then hangs.
Code:#include <ctime> #include <iostream> #include <string.h> #include <array> using namespace std; int main() { time_t now; now=time(NULL); char * today=ctime(&now); cout<<"The date is: "<<today<<endl; array<string,7> info = {{"a", "a", "a", "a", "a", "a", "a"}}; //day month date hour minute second year char *temp; int x=0; temp = strtok (today," :"); info[x]=temp; while (today != NULL) { cout<<temp<<endl; x++; temp = strtok (NULL, " :"); info[x]=temp; } for(int x(0);x<=6;x++) cout<<"Info ["<<x<<"] is : "<<info[x]<<endl; return 0; }



LinkBack URL
About LinkBacks


