Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ad-graph ~~ csv_parse/gen.c
- * By Asha Dixon, 2018 */
- /* This file is for TESTING ONLY. It generates n amount
- * of CSV records and outputs them to stdout. For now, it
- * only generates XY/YX records. */
- #include <stdio.h>
- #include <stdlib.h>
- #include <errno.h>
- int main ( int argc, char ** argv ) {
- char * end_ptr = NULL;
- unsigned long record_count = 0;
- if ( argc < 2 ) {
- fprintf ( stderr, "syntax: number of records to generate\n" );
- return EXIT_FAILURE;
- }
- // convert the argument to a number
- if ( ( ( record_count = strtoul ( argv[1], &end_ptr, 10 ) ) == 0 && errno != 0 )
- || *end_ptr != '\0' ) {
- fprintf ( stderr, "could not convert the given record count: %s\n", argv[1] );
- return EXIT_FAILURE;
- }
- // generate the records
- for ( unsigned long i = 0; i < record_count; i++ )
- printf ( "%ld,%ld\n", i, -i );
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment