include cstdio include cstring using namespace std int main char words

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
char words[1024] = "azaza,adadac,adadad,ac";
char word[256];
size_t len = strlen(words), j = 0;
for (size_t i = 0; i < len; ++i) {
if (words[i] != ',')
word[j++] = words[i];
if (words[i] == ',' || i == len - 1) {
word[j] = '\0';
if (word[j - 1] == 'c')
printf("%s\n", word);
j = 0;
}
}
return 0;
}