Guest User

Untitled

a guest
Jul 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. /* ad-graph ~~ csv_parse/gen.c
  2. * By Asha Dixon, 2018 */
  3.  
  4. /* This file is for TESTING ONLY. It generates n amount
  5. * of CSV records and outputs them to stdout. For now, it
  6. * only generates XY/YX records. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <errno.h>
  11.  
  12. int main ( int argc, char ** argv ) {
  13. char * end_ptr = NULL;
  14. unsigned long record_count = 0;
  15.  
  16. if ( argc < 2 ) {
  17. fprintf ( stderr, "syntax: number of records to generate\n" );
  18. return EXIT_FAILURE;
  19. }
  20.  
  21. // convert the argument to a number
  22.  
  23. if ( ( ( record_count = strtoul ( argv[1], &end_ptr, 10 ) ) == 0 && errno != 0 )
  24. || *end_ptr != '\0' ) {
  25. fprintf ( stderr, "could not convert the given record count: %s\n", argv[1] );
  26. return EXIT_FAILURE;
  27. }
  28.  
  29. // generate the records
  30.  
  31. for ( unsigned long i = 0; i < record_count; i++ )
  32. printf ( "%ld,%ld\n", i, -i );
  33.  
  34. return EXIT_SUCCESS;
  35. }
Add Comment
Please, Sign In to add comment