伙计们,我想找到此strcat(或strlen)出现此问题的原因:
我写的时候:
int main(int argc, char* argv[])
{
if(argv[1] != '\0')
{
const char* navegador = "C:\\Program Files\\Mozilla Firefox\\firefox.exe ";
const char* puerto = "localhost:80/";
char* archivo = argv[1];
char comando[2] = "\"";
strcat(comando,navegador);
int size = strlen(comando); // ISSUE UNCOMMENTED!
printf("command is: %s\n",comando);
}
else
{
printf("is null!\n");
}
return 0;
}
其输出是:
D:\camil\Documents\mis_documentos\configs\sublime_text>program.exe someOption
command is: "C:\.
当我评论问题声明时,其输出为:
D:\camil\Documents\mis_documentos\configs\sublime_text>program.exe someOption
command is: "C:\Program Files\Mozilla Firefox\firefox.exe"
为什么strlen会改变输出,看来strlen会影响strcat的行为。