0

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

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() 被忽略

请帮忙 :/

4

1 回答 1

0

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.
}

或类似的镜头。

于 2017-12-05T01:08:25.370 回答