Warning
This page is located in archive. Go to the latest version of this course pages.

Covid HW 03 - Heap, structures and files

Write a program that:

  • reads data from the standard input until End Of File is present (Ctrl + D). The maximum count of input data is 20 items.
  • save the input data into an array which is dynamically created in the heap section of the program memory.
  • save these data into an array of structures holding info about the input entry and index of an item read from standard input. The structure definition should look like:

typedef struct tItem
{
  int iItemIndex; // index of input data entered to the program
  int iData; // data element to be entered into the program
} tItem;

  • the program will save all the data (the structures) into a file whose name was given as a parameter of the program on the command line. If the first parameter is missing the program will return error and if everything works fine the program will return ok value. The data will be saved in binary format.
  • the program will work properly with input data provided by redirection of standard input, such as:

./yourprogramname < inputfile.txt

courses/be5b99cpl/hw/hw03c.txt · Last modified: 2020/10/06 08:22 by pacesp