Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //linux, 64bit, gcc, -Wall -Wextra -Wpedantic -Wshadow
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct TestStruct {
- int a;
- int b;
- int c;
- } TestStruct;
- typedef enum TestEnum {
- E_0 = 0,
- E_1 = 1,
- E_2 = 2
- } TestEnum;
- void f0( TestStruct s )
- {
- printf( "%d %d %d\n", s.a, s.b, s.c );
- }
- void f1( int* p, unsigned int n )
- {
- for ( unsigned int i = 0; i < n; ++i )
- {
- printf( "%d ", p[i] );
- }
- printf( "\n" );
- }
- void f2( TestEnum *e, unsigned int n )
- {
- for ( unsigned int i = 0; i < n; ++i )
- {
- printf( "%d ", e[i] );
- }
- printf( "\n" );
- }
- int main()
- {
- TestStruct s = { 1, 2, 3 };
- f0( s );
- f0( (TestStruct){ 4, 5, 6 } );
- int arr[]={ 1, 2, 3 };
- f1( arr, 3 );
- f1( (int[]){ 4, 5, 6 }, 3 );
- TestEnum te[] = { E_0, E_2 } ;
- f2( te, 2 );
- f2( (TestEnum[]){ E_2, E_1 }, 2 );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment