I made this program that tokenizes a date based on the "/" character. However, the test string below the if statment is never executed. How come? There are two 12's in my date, it should print out the test string twice.
Code:
#include <iostream>
#include <cstring>
using namespace std;
void checkDate( char * );
int main(){
char date[] = "12/12/2005";
checkDate( date );
return 0;
}
void checkDate( char * x ){
char * token;
char test[] = "12";
token = strtok( x, "/" );
while( token != NULL ){
cout << token << endl;
if( token == test )
cout << "this is a test string" << endl; // how come I don't see this output???
token = strtok( NULL, "/" );
}
}