It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center。
7年前关闭。
我想使用system()函数打开名称在运行时指定的图像。对于固定名称,它可以工作,但是如果我传递另一个参数,则会出错,因为它没有为两个参数定义。
我想要使用任何可以实现此目的的函数,如下所示。
其中file1存储在运行时给定的文件名。
谢谢!
7年前关闭。
我想使用system()函数打开名称在运行时指定的图像。对于固定名称,它可以工作,但是如果我传递另一个参数,则会出错,因为它没有为两个参数定义。
我想要使用任何可以实现此目的的函数,如下所示。
system("gthumb <file1>");
其中file1存储在运行时给定的文件名。
谢谢!
最佳答案
您应该避免使用system()
调用。
无论如何,您首先要做的是使用sprintf()计算完整的命令行。您必须执行以下操作:sprintf(string, "gthumb %s", file1);
,然后调用system(string);