SHARE
TWEET

Untitled

a guest Mar 20th, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdint.h> // for uint8_t
  2. #include <stdlib.h> // for malloc()
  3. #include <string.h> // for memset()
  4. #include <stdio.h>
  5. #include <math.h>
  6. #include <assert.h>
  7.  
  8. #include "intarr.h"
  9.  
  10. void print_intarr(intarr_t* ia)
  11. {
  12.   if (ia != NULL )
  13.   {
  14.     printf("Printing intarr of length %d:\n", ia->len);
  15.     for( unsigned i=0; i<ia->len; i++ )
  16.       printf( "%d ", ia->data[i] );
  17.     puts( "(end)" );
  18.   }
  19.   return;
  20. }
  21.  
  22. int main( int argc, char* argv[] )
  23. {
  24.   printf("Creating test_ia\n");
  25.   intarr_t* test_ia = intarr_create( 10 );
  26.   if ( test_ia ==  NULL ) {
  27.     printf("test_ia ==  NULL\n");
  28.     return 1;
  29.   }
  30.  
  31.   printf("Populating test_ia\n");
  32.   // Put data in the array
  33.   for( unsigned i=0; i<test_ia->len; i++ )
  34.     test_ia->data[i] = i;
  35.  
  36.   printf("Printing test_ia\n");
  37.   print_intarr( test_ia );
  38.  
  39.   printf("Destroy test_ia\n");  
  40.   intarr_destroy( test_ia );
  41.  
  42.   return 0;
  43. }
RAW Paste Data
Top