打印到命令提示符

时间:2019-03-21 14:34:47

标签: c command-prompt .obj

我是新来的。我正在编写多个程序,每当我在命令提示符下运行它们时,都会产生一个.obj文件。反正有什么可以阻止这个?

int getComments(const char *fileName)
{
    char line[300];
    int comment = 0;
    FILE *fp = fopen("string_functions .c", "r");
    if (fp == NULL) {
        printf("Error: Could not open specified file!\n");
        return -1;
    }
    else {
        while(fgets(line, 300, fp)) {
            int i = 0;
            int len = strlen(line);
            comment++;
            for (i = 0; i < len; i++) {
                if (strstr(line, "//")) {
                    comment--;
                    break;
                }
            }
        }
        return comment;
    }
}

int main(void)
{
    const char fileName[] = "string_functions .c";
    int comments = getComments(fileName);
    if (comments >= 0) {
        printf("The number of comments is %d", comments);
    }       
    return 0;
}

0 个答案:

没有答案