Search code examples
cfunctionstructon-the-fly

C function and struct on the fly


I would to know if t's possible in to initialise struct on the fly for function call like in c++ :

struct point {
  int x;
  int y;
};

some_function(new point(x,y));

Thx :)


Solution

  • Yes. You can use compound literals, introduced in C99.

    some_function((struct pint) {5, 10});