Java and C are different languages with different idioms.
If it were me, I'd refrain from trying [too hard] to coerce C into "Java-like". Embrace each language on its own merits.
For your first example, the "ugly" one, you could use a CPP [C preprocessor] macro--a concept that does not exist in Java:
#define FOO(_av...) \
do { \
char *myArr[] = { _av, NULL }; \
foo(myArr); \
} while (0)
FOO("hello", "my", "friend");
But, this would probably be regarded by many as "too cute". Better to create a table of some sort.
Whenever Java does a new
it is doing a heap allocation [which is slow]. That's partly because everything has to be "on the heap", more or less.
C can do this with malloc
, but a good C programmer will try to avoid unnecessary heap allocations because it has globals, statics, and function scoped variables.