NPPExec scanf Notepad ++ Console

时间:2017-12-05 00:52:42

标签: c notepad++ scanf nppexec

我对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()

请帮忙:/

1 个答案:

答案 0 :(得分:0)

in

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

或类似的东西。