Skip to content

Instantly share code, notes, and snippets.

@iwillspeak
Created June 5, 2014 07:54
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 iwillspeak/1383bb235aecf0c81e1a to your computer and use it in GitHub Desktop.
Save iwillspeak/1383bb235aecf0c81e1a to your computer and use it in GitHub Desktop.
Word!
#include <wordexp.h>
#include <stdio.h>
void expand_word(const char * word) {
wordexp_t words = {0};
puts(word);
wordexp(word, &words, WRDE_NOCMD);
for (int i = 0; i < words.we_wordc; i++) {
printf("%s[%d] = %s\n", word, i, words.we_wordv[i]);
}
wordfree(&words);
}
int main(int argc, const char * argv[]) {
for (int i = 1; i < argc; i++) {
expand_word(argv[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment