即时尝试concatsomm字符串,并调用我的服务器上的exxt脚本,但即时通讯.net程序员和新的C和指针,所以不断弄乱...我是什么在这里做错了吗?如何字符串concat和调用系统的字符变量
或更好的问题将是我应该怎么做到这一点?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
//location of expect script that ssh and gets info on other server
char str0[] = "./home/systemio/Develop/getfile ";
char* strP = argv[1];
char str1 = (char)*strP;
char str2[] = " > file.txt";
strcat(str0,str1);
strcat(str0,str2);
printf("%s\n", str0);
system(str0);
printf("Done!!!!\n");
return 0;
}
为什么的argv [1] [0],而不仅仅是做argv [1]? – systemio
,因为他只接受argv [1]的第一个字符,而不是整个字符串。 (看看%c而不是%s) –
@systemio更新了我的答案。我还可以建议你阅读更多关于指针的信息,以及表达式行“* pointer”的作用? –