Skip to content

Instantly share code, notes, and snippets.

@garethlewin
Created February 4, 2021 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garethlewin/c9474bf084bcade98619719243591687 to your computer and use it in GitHub Desktop.
Save garethlewin/c9474bf084bcade98619719243591687 to your computer and use it in GitHub Desktop.
#include <cstdio>
using namespace std;
int main(int argc, char** argv) {
printf("[");
char* cur = argv[1];
int count = 1;
for (;*cur;++cur, ++count) {
if (cur[0] != cur[1]) {
printf("(\"%c\", %ld)%s", cur[0], count, cur[1] ? " ,": "");
count=0;
}
}
printf("]\n");
}
print('[("a", 4), ("b", 3), ("c", 2), ("a", 1)]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment