开发者

sending input parameters to another function

开发者 https://www.devze.com 2023-02-18 22:19 出处:网络
I need to send the list of the input arguments to readInput function. But the compiler gives error when I call readInput funct开发者_如何学编程ion. Could you please tell me where my mistake is?

I need to send the list of the input arguments to readInput function. But the compiler gives error when I call readInput funct开发者_如何学编程ion. Could you please tell me where my mistake is?

bool readInput(netcorr net,int argc, char * argv[]);

int main(int argc, char * const argv[]) {
    netcorr net;
    bool error=readInput(net, argc, argv);
}

bool readInput(netcorr &net,int argc, char * argv[])
{
}

thanks for your help. Pegah

Edit: The compiler says

Fehler: Argument 3 von »bool readInput(netcorr, int, char**)« wird initialisiert

Fehler: ungültige Umwandlung von »char* const*« in »char**«

Translation by aschepler:

Error: Argument 3 of 'bool readInput(netcorr, int, char**)' is initialized

Error: invalid conversion from 'char* const*' to 'char**'


Because you try to redirect char * const[] to char*[]. Change your main function to get cahr *[] or change readInput function to get char *const[].


You declared a function taking netcorr as it's first argument, and then defined one taking netcorr& as it's first argument. In addition, you tried to pass a char* const[] as a char*[].

0

精彩评论

暂无评论...
验证码 换一张
取 消