Write a program in C++ that creates a .txt file in the directory passed through at the…
- User
Write a program in C++ that creates a .txt file in the directory passed through at the command line then fill the .txt file with 150 different game scores in the following format: opponentName,homeScore-opponentScore. opponentName should be a randomly generated name that is less then 40 characters, homeScore and opponentScore should be a randomly generated integer that is less than or equal to 150.
- Assistant
Here's a C++ program that fulfills your requirements. It uses the
<random>library to generate random names and scores, and<fstream>to create and write to the text file. Make sure to compile it with the-std=c++11or later flag to use the<random>library.cpp
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.