UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2017 - January 2018

14.13.5.  Designing, creating and compiling a C program

Resources

Work Plan

  1. Open the above documents in which both the most common options of the gcc compiler and the main uses of the printf function are explained. Keep them handy to check while writing and compiling the program.

  2. Make a folder src into your work folder.

  3. Download the files data_read.o corresponding to your architecture, menu.h, menu_operations.c and copy them into the folder src created previously in your work space.

  4. Design and write the application code that meets the functionalities of: loading to an array from a given static array the wifi networks information scaned by a mobile phone, printing the list of networks on screen, printing the information of a selected network and exiting of the program. The program should print on screen a menu including four options such as is shown in the figure below.

    • Define the components (files: .c, .h) will be involved in your application. In order to achieve it you should group the functions according to the program functionalities (e.g. main function, show menu, menu operations and heading files). Take as starting point the two given files menu.h and menu_operations.c.

    • Write the code of the void menu() function that prints the menu on screen.

    • Create the main() function. Then you should define the local variables required for the program operation, among others, you must define a variable of long int type which will receive the returned value by data_read() function that captures the keyboard entry. The code of this function is included into data_read.o file which you should include into the compilation command when you compile your program. You must also define a local array variable of 6 positions of struct ap_scan_info type to store the wifi network information. This structure is defined in the given menu.h. file

    • Create the functions needed to implement the functionalities of each one of the menu options:

      • The [1] option initialize the local array defined into main() function with the data stored into wifi array, defined as static variable in the funtion array_load() into the file menu_operations.c

      • The option [2] print on screen the wifi networks data loaded to the array. The format of the printed data are such as shown the following figure..

      • The [3] option prints the information on a selected wifi. To choose the wifi a value betwen 1 and 6 should be typed on keyboard. The format of the printed data are such as shown the following figure.

      • The [4] option ends the program execution, and returns to the operating system.

  5. Compile the program by using the gcc command. You should include in the compilation command the files .c and the given data_read.o file.

  6. Modify your source code so that the resulting output is valid for the proposed self-checking script. You can show the result to your advisor.