在Visual C ++中进行调试时,main()中的参数被忽略

到目前为止,我已经能够使用Visual C ++中的debugging命令正确查看我的C代码的输出。 但是,当脚本依赖于main函数中的参数(例如/ argcargv )时,调试器似乎忽略这两个参数并将它们视为未初始化。

例如,在以下代码中,输出始终为printf("Usage: find pattern\n");

 #include  #include  #define MAXLINE 1000 int getline(char *line, int max); /* find: print lines that match pattern from 1st arg */ main(int argc, char *argv[]) { char line[MAXLINE]; int found = 0; if (argc != 2) printf("Usage: find pattern\n"); else while (getline(line, MAXLINE) > 0) if (strstr(line, argv[1]) != NULL) { printf("%s", line); found++; } system("Pause"); return found; } int getline(char *s, int lim) { int c; char *i = s; while (--lim > 0 && (c=getchar()) != EOF && c != '\n') *s++ = c; if (c == '\n') *s++ = c; *s = '\0'; return si; } 

如何运行代码以便使用argc和argv? 我是否应该使用Visual C ++以外的IDE?