#include <stdio.h>
void splitString(const char *str, const char delimiter) {
char substr[100];
int substr_idx = 0;
for (int i = 0; str[i] != '\0'; i++) {
if (str[i] == delimiter) {
substr[substr_idx] = '\0';
printf("%s\n", substr);
substr_idx = 0;
} else {
substr[substr_idx++] = str[i];
}
}
// Print the last substring after the loop ends (no delimiter after it).
substr[substr_idx] = '\0';
printf("%s\n", substr);
}
int main() {
char str[] = "Hello,World,How,Are,You";
char delimiter = ',';
splitString(str, delimiter);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: