且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

动态Char数组问题

更新时间:2023-11-14 11:01:04


\\ \\ 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).

展开 | 选择 | 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