Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code compiles but I'm not sure why it crashes. The file im grabbing is a list with 100 names, one name per line. I'm

image text in transcribedimage text in transcribed

The code compiles but I'm not sure why it crashes. The file im grabbing is a list with 100 names, one name per line. I'm trying to use a for loop to iterate through every line until I get to the line I want and grab that name and store it into a char array. Please keep it to no other array than the one I've used.

The player will play against a simulated opponent. The opponent will be named by reading a name from a provided text file. You will pick the name by generating a random number between 0 and the number of names in the file and reading that number name in the file. The sample file provided will have 100 names. IE: If the code randomly generates 23 it would read and skip 22 names then read Delicia and store that as the opponent's name. Note: the longest name in the provided file is 9 characters long, so you can simply create a character array size 10 to fit any name: char name [10]; FILE *f; f = fopen("random_names.txt","r"); int namenum = Random InRange(1,100); int i; for(i = 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

Justify the solution formulas (9.31) and (9.32).

Answered: 1 week ago

Question

How can speakers manage speaking anxiety?

Answered: 1 week ago

Question

To what extent is public speaking similar to conversation?

Answered: 1 week ago