Skip to content

Instantly share code, notes, and snippets.

@su8
Created November 1, 2025 02:38
Show Gist options
  • Select an option

  • Save su8/cc95b1c5941a613609d8516d89cc8d3e to your computer and use it in GitHub Desktop.

Select an option

Save su8/cc95b1c5941a613609d8516d89cc8d3e to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <string>
int main(void) {
unsigned short int y = 0U;
unsigned short int z = 0U;
char buf[4096] = {'\0'};
char folders[100][4096] = {'\0'};
char wordStr[] = "-m /home/user /usr /tmp";
char *allptr = wordStr;
/*
char *bufptr = buf;
for(; *allptr;) {
//if (*allptr == '-' && (*(allptr+1) == 'b' || *(allptr+1) == 'm')) { allptr++; allptr++; continue; }
if (std::isspace(*allptr)) { y++; allptr++; continue;}
*bufptr++ = *allptr++;
snprintf(folders[y], sizeof(buf), "%s", buf);
}
*/
//while ((token = strtok_r(allptr, " ", &allptr))) { if(!strcmp(token, "-m")){continue;}snprintf(folders[y++], sizeof(buf), "%s", token); }
for (; z < y; z++) { puts(folders[z]); }
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment