Skip to content

Instantly share code, notes, and snippets.

@repen
Created July 20, 2023 19:04
Show Gist options
  • Save repen/5a235a4348942731146d3a8991494365 to your computer and use it in GitHub Desktop.
Save repen/5a235a4348942731146d3a8991494365 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int main() {
char input[] = "[ 5 6] [ 1 2 ] [0 3] [ 7 8 ]";
char *token = strtok(input, " []");
int count = 0;
while (token != NULL) {
if (count % 2 == 0) {
printf("%s, ", token);
} else {
printf("%s\n", token);
}
token = strtok(NULL, " []");
count++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment