The second and third calls to strtok should have a NULL as first parameter, try to replace
temp = strtok(input, " ");
temp2 = strtok(input+2," ");
temp3 = strtok(input+4," ");
by
temp = strtok(input, " ");
temp2 = strtok(NULL, " ");
temp3 = strtok(NULL, " ");
Then you don't need the if input[0], if input[2], ...
See the doc for strtok: http://www.cplusplus.com/reference/cstring/strtok/