Passing array as argument to a function

Posted By: anissyo

Passing array as argument to a function - 08/21/22 09:23

Hello guys,

I just want to know why I can't use an array as an argument in C-lite, I think it's not possible, can someone please tell me if it's supported or not? thanks in advance =)

this code compiles normally :
Code
void delete_from_array(int index_to_del){	
}



this code does not compile and returns "syntax error" :
Code
void delete_from_array(int index_to_del, float array_to_del_from[]){	
}



Many thanks
Posted By: AndrewAMD

Re: Passing array as argument to a function - 08/22/22 16:00

In Lite-C, you use a pointer instead. So this likely does what you want:
Code
void delete_from_array(int index_to_del, float* array_to_del_from){

    //examples:
    float foo = array_to_del_from[3];
    array_to_del_from[2] = 0;
}
Posted By: anissyo

Re: Passing array as argument to a function - 08/23/22 13:42

Thank you so much Andrew for your help =) =)
© 2024 lite-C Forums