Question: c programming write a program which expects the name of...
Write a program which expects the name of an input file and an output file to be given by the user. If the user does not input any names, default file names should be used, such asin.txt, and out.txt. The input files have lines which look like this:
The string represents a stock symbol. The number represents the number of shares bought for that stock.
Any stock/shares can be represented any number of times in the input file. Your program will create an output file which contains each stock name once followed by the number of shares. Here is an example. If the input file contains the following data:
the output file will contain each stock symbol once followed by the total number of shares for that stock:
Read data from the first input file into a dynamically allocated array of STOCK structures. You may assume that the maximum size of a name string is 25. The program should use either the insertion sort algorithm or the selection sort algorithm to sort the array in ascending order by stock name. To demonstrate that the sorting algorithm works, display the sorted array to the screen. Create your own input file using the data shown on the next page. On the first line in the input file provide the number of stock/shares lines. Make sure that your program does not produce memory leaks. Run the program once and save the output at the end of the source file as a comment.
To check if memory was released properly, use CrtDumpMemoryLeaks as described below:
// . . .
printf( _CrtDumpMemoryLeaks() ? "Memory Leak\n": "No Memory Leak\n");
return 0; } // end of main()
_CrtDumpMemoryLeaks is a debug function: . returns TRUE if a memory leak is found; . otherwise, the function returns FALSE.
Required Header: #include