mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-01-13 08:48:25 +00:00
[SPCA] Finish stack, data type compilation details
This commit is contained in:
10
semester3/spca/code-examples/00_c/03_others/00_variadic.c
Normal file
10
semester3/spca/code-examples/00_c/03_others/00_variadic.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <stdarg.h> // Variadic function utilities
|
||||
#include <stdio.h>
|
||||
|
||||
void print_int( unsigned int num_ints, char *msg, ... ) {
|
||||
va_list ap; // keeps track of current argument, similar (in concept) to iterator
|
||||
va_start( ap, msg ); // Initialize the iterator based on last fixed arg
|
||||
for ( int i = 0; i < num_ints; i++ )
|
||||
printf( "int %d = %d\n", i, va_arg( ap, int ) ); // Returns next arg cast to int
|
||||
va_end( ap ); // Free up iterator
|
||||
}
|
||||
Reference in New Issue
Block a user