c - Why am I getting Expected Identifier or '('? -


i'm learning c , trying write simple program. here code:

#include <stdio.h>  int[] getnumbers( int x, int y, int z );  int main() {     int[] thenumbers = getnumbers(5,6,7);     return 0; }  int[] getnumbers( int x, int y, int z) {     int[] numbers = { x, y, z };     return numbers; } 

i can't figure out issue is.

here's example approach works in c. there better approaches, it's unclear actual goals are. illustrates ways of handling trying do, in working c. c going more rigid , explicit language java. java happens have taken syntax c/c++.

#include <stdio.h>  typedef struct { int a[3]; } int_array;  int_array getnumbers( int x, int y, int z );  int main() {     int_array thenumbers = getnumbers(5,6,7);     printf( "%d, %d, %d\n", thenumbers.a[0], thenumbers.a[1], thenumbers.a[2] );     return 0; }  int_array getnumbers( int x, int y, int z) {     int_array numbers = { x, y, z };     return numbers; } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -