Is it possible to pass an anonymous array to the function when calling it, such as with a string? Why is Example 2 not working? How to make it work without using unnecessary variables?
example 1
void foo(char *arr) { cout << arr[2]; }; int main() { foo("123"); } example 2
void foo(int *arr) { cout << arr[2]; }; int main() { foo({1,2,3}); }