Created
July 20, 2023 19:04
-
-
Save repen/5a235a4348942731146d3a8991494365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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