[ create a new paste ] login | about

Link: http://codepad.org/4SKeYpQc    [ raw code | output | fork ]

AaronMiller - C++, pasted on Sep 15:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * C versus C++ test
 * Structures with initializations based on field names
 */
#ifdef __cplusplus
# include <cstdio>
#else
# include <stdio.h>
#endif

struct test_s {
  int apple;
  float orange;
} g_test = { .apple=42, .orange=3.1415926535f };

int main() {
  printf("apple: %d\norange: %f\n", g_test.apple, g_test.orange);
  return 0;
}


Output:
1
2
Line 14: error: expected primary-expression before '.' token
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: