Home Segments Index Top Previous Next

594: Mainline

The version of the analyze_trades program in Segment 573 contains a wired-in character string supplied when the analyze_trades program was written. Generally, you want a way to have your program ask you for a file-specifying character string at run time. Then, once you have supplied that file-specifying character string, your program can read information from it.

You can, for example, include the following code, which leads to the insertion of a file-specifying character string into the input_buffer character array:

printf ("Please type the name of a trade file.\n"); 
scanf ("%s", input_buffer); 

Next, you can use that file-specifying character string instead of wired-in character string:

analysis_target = fopen(input_buffer, "r");