Created
June 5, 2014 07:54
-
-
Save iwillspeak/1383bb235aecf0c81e1a to your computer and use it in GitHub Desktop.
Word!
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 <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