initialize integer array inline when passing arguments to a method Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of initialize integer array inline when passing arguments to a method without wasting too much if your time.

The question is published on by Tutorial Guruji team.

Is it possible to initialize an integer array inline when calling a method in c++ (avr-g++)?

This is what I tried:

A({2, 4, 8, 3, 6});

void A(int* b) {

}

And I got this error:

cannot convert ” to ‘int*’ for argument ‘1’ to ‘void A(int*)’ cannot convert ” to ‘int*’ for argument ‘1’ to ‘void A(int*)’

Answer

Looking at my old question I figured out I actually know the answer to this now. Here goes:

void A(int *b) {

}

void foo() {
    A((int[]){1,2,3});
}
We are here to answer your question about initialize integer array inline when passing arguments to a method - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji