[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tutorial to Linux gaming




> In Alexander Courbot's tutorial there was this kind of function as
> main:
> 
> int displaypcx(int argc, char **argv);
> 
> I changed it so that it can be called from an other program (I
> think).
> 
> But how should I call it?
> 
> char tausta[] = "tausta.pcx";
> int main()
> {
> displaypcx(2, tausta[1]);
> }

displaypcx need  a char ** argument, tausta[1] is a char.
The correct call should be: displaypcx(1,&tausta) (because tausta is a
char*, so &tausta is a char**)
Anyway it will not work, because when the original program is called,
argv[0] is the name of the program ("displaypcx") and argv[1] is the
first argument. Your string is located at &(tausta)[0]. So the function
will search for &(tausta)[1], and segfault. The best thing to do is to
modify the displaypcx function to your needs :)

Alex.