简体   繁体   English

C编程-如何将输出图片文件设置为.pgm格式?

[英]C Programming-how to set output picture file to .pgm format?

Instead of asking user to enter output name I need the program to automatically create it as out1.pgm. 而不是要求用户输入输出名称,我需要程序自动将其创建为out1.pgm。 How can do I it? 我该怎么办?

       {
        printf("Enter image filename: ");
        scanf("%s", fileName);

        img = readpic(fileName);

        printf("Successfully read image file '%s'\n", fileName);
        printf("Adjust brightness: ");
        scanf("%d", &brightness);

        option1(img, brightness);

        printf("Enter image filename for output: ");
        scanf("%s", fileName);

        writeoutpic(fileName,img);



        free(img);
        img = NULL;
        return(EXIT_SUCCESS);
    }

Change scanf("%s", fileName); 更改scanf("%s", fileName); to strcpy(fileName, "out1.pgm"); strcpy(fileName, "out1.pgm");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM