# Getting Coverage Summary Information on Demand

This API is supported only on Linux* OS for C/C++ applications.

The _PGOPTI_Get_Coverage_Info() function gets the basic-block and line coverage percentage for each instrumented file while the application is running.

The prototype of the function call is given below.

Syntax
`int _PGOPTI_Get_Coverage_Info(PGOPTI_COVERAGE_SUMMARY *coverage_array);`

This API provides on-demand coverage information for all the files that get profiled. The coverage information is stored in a dynamically allocated array of structures, a pointer to which is returned in the argument coverage_array. The return value of the call is the number of elements in this array.

You can use the coverage information as needed but you are responsible for freeing up the dynamically allocated coverage array.

You can also choose to print the on-demand coverage information onto the terminal screen as shown in the example below.

    #include <pgouser.h>
    void Coverage_Summary(void)
    {
        int index, num_files;
        PGOPTI_COVERAGE_SUMMARY coverage_array, curp;
        // Get coverage summary information and print it out
        num_files =  _PGOPTI_Get_Coverage_Info(&coverage_array);
        for (index = 0; index < num_files; index++) {
            curp = &coverage_array[index];
            printf( "%s ", curp->file_name);
            printf( "Block coverage percent: %u, ", curp->coverage_percent);
            printf( "Line coverage percent: %u\n", curp->line_coverage_percent);
            free(curp->file_name);
        }
        if (num_files > 0) {
           free(coverage_array);
        }}

Parent topic: PGO API Support