Skip to content

Instantly share code, notes, and snippets.

@angelcaru
Created March 8, 2025 18:16
Show Gist options
  • Save angelcaru/49eaa750eddb7d8e6100e0fdf94d0492 to your computer and use it in GitHub Desktop.
Save angelcaru/49eaa750eddb7d8e6100e0fdf94d0492 to your computer and use it in GitHub Desktop.
#include <stdarg.h>
#include <string.h>
int switchcmp(char *tc, ...) {
va_list args;
va_start(args, tc);
const char *arg;
int c = 0;
while ((arg = va_arg(args, const char *)) != NULL) {
if (strcmp(tc, arg) == 0) {
va_end(args);
return c;
}
c++;
}
va_end(args);
return -1;
}
@zhrexx
Copy link

zhrexx commented Mar 8, 2025

thanks for formatting it 👍

@angelcaru
Copy link
Author

you're welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment