获取多个值与scanf()的 [英] Getting multiple values with scanf()

查看:189
本文介绍了获取多个值与scanf()的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用scanf()的获得一组从用户的整数。不过,我想用户在提供所有4个整数一次而不是4个不同的promps。我知道我可以做得到一个值:

I am using scanf() to get a set of ints from the user. But I would like the user to supply all 4 ints at once instead of 4 different promps. I know I can get one value by doing:

scanf( "%i", &minx);

不过,我想用户能够做这样的事情:

But I would like the user to be able to do something like:

Enter Four Ints: 123 234 345 456

是否有可能做到这一点?

Is it possible to do this?

推荐答案

您可以通过一个调用做到这一点,就像这样:

You can do this with a single call, like so:

scanf( "%i %i %i %i", &minx, &maxx, &miny, &maxy);

这篇关于获取多个值与scanf()的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆