replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cerr << "Error: Wrong usage\n";
return -1;
}
std::ifstream infile(argv[1]);
std::string word;
whilecopy(std::istream_iterator<std::string>(infile >> word),
{
std::cout << WordInfoistream_iterator<std::string>(word) << "\n";,
}
// Actually I would replace this loop with std::copy
/*
std::copyostream_iterator<WordInfo>(std::istream_iterator<std::string>(infile)cout, "\n")
std::istream_iterator<std::string>(),;
}
Note: The std::copy above acts like this:
std::string word;
std::ostream_iterator<WordInfo>while(std::cout,infile "\n">> word)
{
std::cout << WordInfo(word); << "\n";
*/
}
int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cerr << "Error: Wrong usage\n";
return -1;
}
std::ifstream infile(argv[1]);
std::string word;
while(infile >> word)
{
std::cout << WordInfo(word) << "\n";
}
// Actually I would replace this loop with std::copy
/*
std::copy(std::istream_iterator<std::string>(infile), std::istream_iterator<std::string>(),
std::ostream_iterator<WordInfo>(std::cout, "\n")
);
*/
}
int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cerr << "Error: Wrong usage\n";
return -1;
}
std::ifstream infile(argv[1]);
std::copy(std::istream_iterator<std::string>(infile),
std::istream_iterator<std::string>(),
std::ostream_iterator<WordInfo>(std::cout, "\n")
);
}
Note: The std::copy above acts like this:
std::string word;
while(infile >> word)
{
std::cout << WordInfo(word) << "\n";
}
Loading
Loading
Loading
lang-cpp