Search code examples
c++carraysfunctionprototype

How to pass the entire char array with its values to another function?


I'm working on how to pass the entire char array including its values to another function. here's the code:

#define STACK_SIZE 100
void Prefix_Conversion(char Infix_Postfix_Expression[STACK_SIZE]); 

int main(){
    //some process code here
    Prefix_Conversion(Infix_Postfix_Expression[STACK_SIZE]);
}

void Prefix_Conversion(char Infix_Postfix_Expression[]){
    //some code here
}

It gives me an error of:

[Error] invalid conversion from 'char' to 'char*' [f-permissive] [Note] initilizing argument of 1 if 'void Prefix_Conversion(char*)'

Is the prototype, arguments and array right?


Solution

  • With Prefix_Conversion(Infix_Postfix_Expression[STACK_SIZE]); you're passing one character to a function that needs char *, hence the error message.

    Simply pass Prefix_Conversion(Infix_Postfix_Expression);