替代的fscanf()/ vscanf()函数用于家庭使用替代验证密钥或如何创建自定义语言布局? [英] alternative to the fscanf()/vscanf() functions family for using an alternative validation key or how to create a custom language layout?

查看:136
本文介绍了替代的fscanf()/ vscanf()函数用于家庭使用替代验证密钥或如何创建自定义语言布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我宁愿知道在C.我知道从标准输入设置变量的唯一方法是通过使用的fscanf() / vscanf ()功能系列。

I am rather knew in C. And the only way I know for setting a variable from stdin is by using thefscanf()/vscanf()functions family.

DOS操作系统都看到在嵌入式市场的复苏。我现在用的设备与DOS编程兼容,使用NEC V30Mx该产品采用80286指令集。结果
问题是内置的键盘不具有回车键,而使用由此进入0x1C00键code中的EXE键的 Alt键进入

DOS operating systems are seeing a resurgence in the embedded market. The device which I am using is programmatically compatible with DOS and use a NEC V30Mx which feature the 80286 instruction set.
The problem is the built-in keyboard doesn’t feature the enter key and instead use the EXE key which enter the 0x1C00 key code (Alt enter).

所以,当我写一个程序是这样的:

So when I write a program like this :

#include <stdio.h>
#include <dir.h>
#include <dos.h>
int main(void) {
    int res, number = 0;
    printf("int value?");
    res = scanf("%d", &number);
    printf("The value is %d", number);
    return;
}

scanf()的被称为和 int值?显示在屏幕上。我可以写数字和大写在前字母。但我无法验证输出,因为没有什么特色的 0x1C0D键code 和EXE键使用不同的密钥code。结果
当然,C有没有键盘的知识,但C标准库的二进制文件查找 0x1C0D关键进入code 一个 \\ n

scanf()is called and "int value?" is displayed on the screen. I can write numbers and upercase letters. but I can’t validate the output since nothing feature the 0x1C0D key code, and the EXE key use a different keycode.
Of course C has no knowledge of keyboard but the C standard library binaries look for the 0x1C0D key code for entering a\n.

那么,有没有到的fscanf() / vscanf()系列函数替代是部分C标准库?

So is there an alternative to thefscanf()/vscanf()functions family which is part of the C standard library?

我想在DOS下最C标准库使用软件实现这样做的。
我看到一个DOS调用读取文件,当然,使用数字0原因从标准输入读取。结果
所以我组装这个例子,装它的计算器和发现自己感到惊讶制造商preferred处理它的内置软件,而不是固定OS的问题... :-(的(我得到了同样的previous结果)

I thought most C standard libraries under dos use software implementation for doing this. I saw a DOS call for reading files and of course, using the number 0 cause to read from stdin.
So I assembled this example, loaded it on the calculator and find myself surprised the manufacturer preferred handling the issue in it’s built-in software rather than fixing the OS... :-( (I got the the same previous result)

我没有想过这个问题,但感谢的意见,我忘了键盘语言做重点code重映。
这样,创建了QWERTY键盘自定义映射将是一个另一种方式来解决这个问题。

I didn’t thought about it but thanks to the comments, I forgot keyboard languages do key code remapping. So, creating a custom mapping for the qwerty keyboard would be an another way to solve the problem.

推荐答案

标准C库来解决这个问题的唯一方法是使用的getchar()(或标准输入龟etc()),以获得一个字符一次时间,检测EXE键,您NUL终止字符串,并把它传递给的sscanf()。

The only way to solve such a problem with standard C library is to use getchar() (or fgetc() on stdin) to get a character one at a time, detect the EXE key yourself, NUL terminate the string and pass it to sscanf().

这篇关于替代的fscanf()/ vscanf()函数用于家庭使用替代验证密钥或如何创建自定义语言布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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