• Jump To … +
    array_of_routines.c array_utils.h print.c arrays_and_pointers.c arrays_basics.c command_line.c fibonacci.c hello_world.c hello_world_correct.c linked_list.c malloc_stuff.c nans_and_other_oddities.c rationals_with_structs.c routine_pointers.c experiments.c naive_sequence_of_longs.c naive_sequence_of_longs.h sequence_of_longs.c sequence_of_longs.h tests.c sizeof_and_arrays.c array_of_doubles.c array_of_doubles.h perform_experiments.c sorting_algorithms.c sorting_algorithms.h string_io.c
  • ¶

    string_io.c – Saídas sobre cadeias de caracteres

  • ¶
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void)
    {
    	const char *types[] = {
    		"sorted",
    		"partially_sorted",
    		"shuffled",
    	};
    	const int number_of_types =
    		sizeof(types) / sizeof(const char*);
    
    	for (int size = 2; size != 1 << 21; size *= 2)
    		for (int i = 0; i != number_of_types; i++) {
    			char filename[FILENAME_MAX];
    			snprintf(filename, FILENAME_MAX,
    				"%s_%d.txt",
    				types[i], size);
    
    			printf("The file name is: '%s'\n", filename);
    		}
    
    	return EXIT_SUCCESS;
    }