Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link
deleted 39 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
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";
 }
added 1 character in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
Loading
added 1071 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
Loading
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /