I'm following these guidelines for a little project in school but am unclear on how to implement this into a separate function? Any suggestions?
I don't want anyone to write code for me, but a little hint would be helpful! :D My below code does exactly what I think these instructions are asking, but just not in a separate function.
I think I declared the prototype correctly but man am I really stumped! Also, what exactly is the "command line"?
get_word: The first function should be called "get_word". It takes two arguments. Every call to this function will fill one of the arguments with a word from the file. You should then output every word you receive and a count of the total number of words to a file specified by the user on the command line. This function doesn't return anything.
#include <iostream>
#include <fstream>
//void get_word(std::ifstream, std::string);
int main()
{
std::ifstream word("io_file.txt");
std::string str1;
int counter = 0;
while(word >> str1)
{
std::cout << str1 << '\n';
++counter;
}
std::cout << "Word count: " << counter << '\n';
}