【问题标题】:NPPExec scanf Notepad++ ConsoleNPPExec scanf Notepad++ 控制台
【发布时间】:2018-05-18 13:40:48
【问题描述】:

我是 NPPExec 和 c 编码的新手。 有没有办法编译和运行类似的c代码

int number;
scanf("enter a number: %d" ,&number);
printf("\nyour number is: %d\n", number);

当我尝试时

NPP_SAVE cd $(CURRENT_DIRECTORY) cmd /c g++ -utf-8 -pedantic -Wall -W -Wconversion -Wshadow -Wcast-qual -Wwrite-strings $(FILE_NAME) -o $(NAME_PART).exe& IF ERRORLEVEL 1 (echo. && echo 发现语法错误在编译期间。) ELSE ( cmd /c "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" -run)

scanf() 被忽略

请帮忙:/

【问题讨论】:

    标签: c notepad++ scanf nppexec


    【解决方案1】:

    int number;
    scanf("enter a number: %d" ,&number);
    printf("\nyour number is: %d\n", number);
    

    看起来您正试图在对scanf 的调用中打印出用户提示。不幸的是,scanf 不是这样做的。

    您需要单独打印出提示。给

    int number;
    prinf("enter a number: ");
    int rval = scanf("%d", &number);
    if (rval == 1) // test that read got something
    {
        printf("\nyour number is: %d\n", number);
    }
    else
    {
        printf("\nyour input is USELESS!\n", number); // though a less mocking tone 
                                                      // is usually appreciated by users.
    }
    

    或类似的镜头。

    【讨论】:

      猜你喜欢
      • 2022-01-20
      • 2012-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-28
      • 1970-01-01
      • 2019-12-13
      • 2012-10-02
      相关资源
      最近更新 更多