Răspuns:
Buna! O mica greseala, ai scris:
cout << s[i] << " "; si
cout << s[i] << " ";
Trebuie sa fie:
cout << cuv[i] << " ";
cout << cuv[i] << " ";
(de aia ti se afisa de 2 ori primul cuvant din s)
Uite codul modificat:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char s[100], *cuv;
int i, l;
cin.getline(s, 100);
cuv = strtok(s, " ");
while (cuv) {
for (i = 0; i <= strlen(cuv) - 1; i++) {
if (i == strlen(cuv) - 1)
cout << cuv[i] << endl;
else
cout << cuv[i] << " ";
}
cuv = strtok(NULL, " ");
}
return 0;
}