I want to pass a text file using input redirection to my program as a command line argument. I would then like the words in this to be randomly printed and whitespace removed.
I would like to run the program as
foo <dict.txt
dict.txt will contain various words, such as
camel penguin tiger chicken
I can currently print the contents of dict.txt using
char line[100];
while(scanf("%[^\n]%*c", &line) == 1) {
printf("%s\n",line);
this would output
camel penguin tiger chicken
I would like it to be random and whitespace removed such as
penguinchickencameltiger
For the most part I am not sure how to approach it, I was thinking of putting it into an array and somehow randomizing it, or using regular expressions but I am not familiar with how to apply these.
Thanks in advance, I am a relatively new coder.