TextPlot and a C-style array

14 kwietnia 2010 21:05 tags:

Aquila::TextPlot can be used to output a one-dimensional data array to console.

#include "aquila/tools/TextPlot.h"
#include <cstddef>

int main(int argc, char *argv[])
{
    const std::size_t SIZE = 64;
    int arr[SIZE];
    for (std::size_t i = 0; i < SIZE; ++i)
    {
        arr[i] = i % 10;
    }

    Aquila::TextPlot plot("Example plot");
    plot.plot(arr, SIZE);

    return 0;
}

The plot should look like this:

Example plot
         *         *         *         *         *         *    
        *         *         *         *         *         *

       *         *         *         *         *         *

      *         *         *         *         *         *

     *         *         *         *         *         *        
    *         *         *         *         *         *

   *         *         *         *         *         *         *

  *         *         *         *         *         *         *

 *         *         *         *         *         *         *  
*         *         *         *         *         *         *
« Return to list