动态Char数组问题 [英] Dynamic Char array problem

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

问题描述

我的classList变量有问题。它是一个动态的字符串数组,用于存储类的名称(我的程序要求学生姓名,课程数量,然后是课程列表)。

Im having trouble with my classList variable. It''s a dynamic array of strings used to store the names of the classes(my program ask for students name, number of classes, then a list of the classes).

展开 | 选择 < span class =codeDivider> | Wrap | 行号

推荐答案


\\ \\ r是回车

\ n是回车+新换行


可能你想要\ n。
\r is carriage return
\n is carriage return + newline feed

Probably you want \n.



如果你想获得技术,在阅读/写入文本文件时,你是正确的......在Windoze下。它虽然不便携。


不同的操作系统对它的定义不同。 IIRC,Unix将\ n定义为仅回车,Mac将其定义为换行+回车(与Windows相反),其他操作系统我不是一个线索。由于这种可移植性问题,我不再使用文本文件了,除非我确信生成的文件永远不会转移到另一个操作系统或我不在乎;)。


Adrian

If you want to get technical, in reading from/writing to a text file you are correct... under Windoze. It is not portable though.

Different operating systems define it differently. IIRC, Unix defines \n as carriage return only, Mac defines it as line feed + carriage return (reverse of Windows), other OSs I haven''t a clue. I no longer work with text files anymore because of this portability issue, unless I am sure that the file generated will never be shifted to another OS or I don''t care ;).


Adrian


我的classList变量出现问题。它是一个动态的字符串数组,用于存储类的名称(我的程序要求学生姓名,课程数量,然后是课程列表)。

Im having trouble with my classList variable. It''s a dynamic array of strings used to store the names of the classes(my program ask for students name, number of classes, then a list of the classes).

展开 | 选择 < span class =codeDivider> | Wrap | 行号


我会使用向量,但这是一个类赋值(我应该有提到。)

作业声明classList?用于存储学生注册的类名称的动态字符串数组


现在我确实将classList = new char []更改为classList = new char [numberClasses ]。但是没有用。
I''d use a vector, but this is a class assignment(which I should have mentioned.)
The assignment stated that "classList ? A dynamic array of strings used to store the names of the classes that the student is enrolled in"

Now I did change classList = new char[], to classList = new char[numberClasses]; but that didnt help.



我会使用一个向量,但这是一个类赋值(我应该提到它。)

作业声明classList?用于存储学生注册的类名称的动态字符串数组


现在我确实将classList = new char []更改为classList = new char [numberClasses ]。但那并没有帮助。
I''d use a vector, but this is a class assignment(which I should have mentioned.)
The assignment stated that "classList ? A dynamic array of strings used to store the names of the classes that the student is enrolled in"

Now I did change classList = new char[], to classList = new char[numberClasses]; but that didnt help.



告诉我如何用向量做到这一点。我们将从那里继续前进。



Adrian

Tell me how you would do it with a vector. We''ll move on from there.


Adrian


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

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