[REPOST]在整数后自动打印一个字符。 [英] [REPOST] print a character automatically after an integer.

查看:53
本文介绍了[REPOST]在整数后自动打印一个字符。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在输入整数后输出 - 字符以获得如下输出

dd-mm-year。

how to print a character that is "-" after enter an integer to get output as follows
dd-mm-year.

推荐答案

这听起来像是一个愚蠢的问题,但是你可能在用户输入时尝试这样做吗?



This may sound like a stupid question, but are you perhaps trying to do this as the user is typing?
I.e.
He types a 1: the console shows a 1.
He types a 2: the console shows "12-"

等等?

因为如果你当时没有标准的方法 - 它不是核心C库的一部分。

但是,如果你有一个在您的系统上查找_getch()或getch(),这样您就可以一次读取一个字符,而无需先等待ENTER键。



你可以然后自己处理回声和额外的字符,但你也可以自己处理字符串形式和任何转换日期。

and so on?
Because if you are then there is no standard way to do that - it's not a part of the core C library.
However, if you have a look for _getch() or getch() on your system, that should allow you to read a character at a time without waiting for the ENTER key first.

You can then handle the echo and extra characters yourself, but you will also have handle the string formation and any conversion to dates yourself as well.


这篇关于[REPOST]在整数后自动打印一个字符。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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