根据变量类型分隔线的方法 [英] the way to separate a line according to variable types
本文介绍了根据变量类型分隔线的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
我期待找到分离整数,字符串和字符的最佳解决方案。
char line [100];
得到(行);
用户输入''有1个房间和90个人''
然后程序分类如下并打印它们
整数= 1,90
字符串=有空间和人''
char = a
我认为使用ascii代码可以做到这一点,但它仍然令人困惑。
如何解决它?需要你的建议
hi
I''m looking forward to finding the best solution for separation of integer,string and char.
char line[100];
gets(line);
user input ''there is a 1 room and 90 people''
then the program classifies like below and print them
integer = 1, 90
string = there is room and people''
char = a
I think it''s possible to do it with using ascii code, but it has been still confusing.
How to solve it? need your advice
推荐答案
看起来你想要一种解析器或至少一个 lexer 。您可以使用 Flex 和 Bison 进行此类操作,这些免费且易于使用Google查找。
是的,所有字符当然都存储为计算机中的数字,从数字到字符的最重要的映射之一是ASCII。
It looks like you want a form of parser or at least a lexer. You can do this sort of thing with Flex and Bison which are free and easy to find with Google.
Yes all characters are of course stored as numbers in a computer and one of the most important mappings from numbers to characters is ASCII.
这篇关于根据变量类型分隔线的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文