Well, I gave a very simplified version of the code, hoping that it would be easy to understand.
You need extra code, read the first line from the file, (instead of ignoring it as I did), display the header values. Then prompt the user to enter which column they would like. In some ways, it would be easier if the user entered a number rather than a string.
Say the column headings look like this:
rain thunderstorm snow gale |
you could output the headings like this
Please choose an option:
1. rain
2. thunderstorm
3. snow
4. gale |
Then the user enters say '2' instead of typing "thunderstorm"
My reason for heading in this direction is that it makes the next part easier.
Once you have a valid number from the user, you can use it to select the required column of data.
Instead of as I put,
cout << b << '\t';
you might have
cout << array[n-1] << '\t';
where n is the number entered by the user.
array[0] to array[3] would replace the variables a to d that I used before.
Finally, how do you 'save' it - to another file I presume - just replace cout with the name of an ofstream which you have previously opened.