字符串数组...... [英] String arrays...

查看:81
本文介绍了字符串数组......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我必须写一个程序,我的老师不知道该怎么做。我已经获得了多行数据,我必须将其读入数组才能在以后访问。我能够将数字读入适当的数组,但字符串给我带来了麻烦。我必须保持整个字符串在一个数组下,我可以将它们称为备份。我需要一个方式2商店infor(已知金额)。

a样本数据如下:


12345678 jones,danny 123f1234jasa 0 1123 1234 2134


i必须获取存储为字符串的这一行数据中的第二个第3和第4项,我可以访问它们。我将拥有如下多行数据,并且永远不知道会有多少数据。我所知道的是2名永远不会超过3个字符,后面的字符串永远不会超过12个。请帮助!!!

解决方案


好​​吧,我必须写一个程序,我的老师不知道该怎么做。我已经获得了多行数据,我必须将其读入数组才能在以后访问。我能够将数字读入适当的数组,但字符串给我带来了麻烦。我必须保持整个字符串在一个数组下,我可以将它们称为备份。我需要一个方式2商店infor(已知金额)。

a样本数据如下:


12345678 jones,danny 123f1234jasa 0 1123 1234 2134


i必须获取存储为字符串的这一行数据中的第二个第3和第4项,我可以访问它们。我将拥有如下多行数据,并且永远不知道会有多少数据。我所知道的是,2名不会超过3个字符,而后面的字符串永远不会超过12个。请帮助!!!



当你说你需要将它们保留一段时间后,你是否试图在程序的生命周期中保留它们,或者你是否需要存储它们(比如在文件中)可以在任意时间读取,可能是几个月后读取的?


你知道字符串是否有最大长度? (某些设置格式,即文件是MS Word - 所以它们每行只有60个奇数字符,等等。)或者它们是没有最大行长度的vi文件?


伙计,如果你能在这里帮助我,你将成为我的英雄。当我说我必须保存以供以后使用时,我的意思是在程序中。我需要在报告中稍后回忆一下程序中的所有数据。所以就像我会读取数据一样报告如下:


客户编号:12345678

客户名称:jones,danny

米#:124; j; ljqwerqr

....依此类推。


我知道每个人的具体时间。数据行将按照我在原始邮件中声明的顺序排列。第一个将始终是数字,最多只有8个字节。名称将是30个字节的最大值(一起),第三个对象(我们称之为米号)将最多为12个数字字节,最后四个数字的大小会有所不同,但我不关心它们。正如我之前提到的,正是这些字符串给我带来了麻烦。我必须制作多个报告并且信息总是会有所不同,所以在行中的最后一个数字之后,序列将以相同的顺序重复。



老兄,如果你能在这里帮助我,你将成为我的英雄。当我说我必须保存以供以后使用时,我的意思是在程序中。我需要在报告中稍后回忆一下程序中的所有数据。所以就像我会读取数据一样报告如下:


客户编号:12345678

客户名称:jones,danny

米#:124; j; ljqwerqr

....依此类推。


我知道每个人的具体时间。数据行将按照我在原始邮件中声明的顺序排列。第一个将始终是数字,最多只有8个字节。名称将是30个字节的最大值(一起),第三个对象(我们称之为米号)将最多为12个数字字节,最后四个数字的大小会有所不同,但我不关心它们。正如我之前提到的,正是这些字符串给我带来了麻烦。我必须制作多个报告,并且信息将始终有所不同,因此在行中的最后一个数字之后,序列将以相同的顺序重复。



嗯,我很确定我们能帮到你这里。下一步是弄清楚你的舒适度/技能水平。如果我要告诉你所有你需要做的就是用分隔符解析每个字符串,你会知道我在说什么吗?


ok, i have to write a program that my teachers has no idea how to do. I have been given multiple lines of data, and i have to read it into arrays to access at a later time. i am able to read the numbers into their appropriate arrays, but the strings are giving me trouble. I must keep the strings whole and under an array where as i can call them back up. I need an way 2 store infor (known amount).
a sample of the data is as follows:

12345678 jones, danny 123f1234jasa 0 1123 1234 2134

i must get the 2nd 3rd and 4th item in this line of data stored as string where as i can access them. i will have multiple lines of data as follows and never know how many there will be. all i know is that the 2 name will never exceed 3 characters and the string after them will never exceed 12. PLEASE HELP!!!

解决方案

ok, i have to write a program that my teachers has no idea how to do. I have been given multiple lines of data, and i have to read it into arrays to access at a later time. i am able to read the numbers into their appropriate arrays, but the strings are giving me trouble. I must keep the strings whole and under an array where as i can call them back up. I need an way 2 store infor (known amount).
a sample of the data is as follows:

12345678 jones, danny 123f1234jasa 0 1123 1234 2134

i must get the 2nd 3rd and 4th item in this line of data stored as string where as i can access them. i will have multiple lines of data as follows and never know how many there will be. all i know is that the 2 name will never exceed 3 characters and the string after them will never exceed 12. PLEASE HELP!!!

When you say you need to keep them for a later time, are you trying to keep them just during the life of the program, or do you need to store them (like in a file) to be read at some arbitrary time, possibly several months from now?

Do you know if the strings have a maximum length? (some set format, ie, the files are MS Word - so they only have 60 some odd characters per line, etc..) Or are they vi files which have no max line length?


Dude, u will be my hero if you can help me here. When i say that i have to save for a later use, i mean in the program. I need to recall all the data later in the program in a report. so like i will read the data a make a report like:

customer number: 12345678
customer name: jones, danny
meter #: 124;j;ljqwerqr
.... and so on and so on.

i do know the specifics on how long each will be also. the lines of data will be in the order as i have stated in the original message. the first will always be numbers and will have a max of eight bytes. the names will be a max (together) of 30 bytes, the third object (lets call it the meter number) will be a max of 12 numeric bytes, and the final four numbers will vary in size, but im not concerned about them. As i mentioned before, it is the strings that are giving me trouble. I must make multiple reports and the info will always vary, so after the last number in the line the sequence will repeat in the same order.


Dude, u will be my hero if you can help me here. When i say that i have to save for a later use, i mean in the program. I need to recall all the data later in the program in a report. so like i will read the data a make a report like:

customer number: 12345678
customer name: jones, danny
meter #: 124;j;ljqwerqr
.... and so on and so on.

i do know the specifics on how long each will be also. the lines of data will be in the order as i have stated in the original message. the first will always be numbers and will have a max of eight bytes. the names will be a max (together) of 30 bytes, the third object (lets call it the meter number) will be a max of 12 numeric bytes, and the final four numbers will vary in size, but im not concerned about them. As i mentioned before, it is the strings that are giving me trouble. I must make multiple reports and the info will always vary, so after the last number in the line the sequence will repeat in the same order.

Well, I''m pretty sure we will be able to help you out here. The next step is figuring out what your level of comfort/skill is. If I was to tell you that all you needed to do was parse each string by delimiter, would you know what I was talking about?


这篇关于字符串数组......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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