在控制台应用程序中获取整数的最简单方法是什么? [英] What is the easiest way to get an int in a console app?
本文介绍了在控制台应用程序中获取整数的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将用户输入处理为整数,但是似乎C无法从stdin获取int。有功能可以做到这一点吗?
I want to process user input as an integer, but it seems as though C has no way to get an int from stdin. Is there a function to do this? How would I go about getting an int from the user?
推荐答案
#include <stdio.h>
int n;
scanf ("%d",&n);
请参见 http://www.cplusplus.com/reference/clibrary/cstdio/scanf/
这篇关于在控制台应用程序中获取整数的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文