gpt4 book ai didi

compiler-errors - C++ scanf 未在此范围内声明

转载 作者:行者123 更新时间:2023-12-02 01:28:48 25 4
gpt4 key购买 nike

这是我的代码

#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
long long int N = 0, product, sum;
int t; scanf_s("%d", &t); //// ERROR STARTS AT THIS LINE
while (t--)
{
sum = 0;

scanf_s("%d", &N);
N = N / 2;

product = 1;
sum = 1;
for (int i = 1; i <= N; i++)
{
product = product * i;
sum += product;
}

printf("%d \n", sum);
}
return 0;
}

我明白了 编译错误向 www.codechef.com 提交解决方案时
prog.cpp: In function 'int main()':
prog.cpp:9:25: error: 'scanf_s' was not declared in this scope
int t; scanf_s("%d", &t);

我试过用 C++ (gcc-4.3.2) 编译, (C++ gcc-4.9.2)C++ 14 (g++4.9.2) ,没用。
为什么..?我已收录 <stdio.h> .

最佳答案

你可以改变scanf_sscanf .

关于compiler-errors - C++ scanf 未在此范围内声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35289142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com