Your problem is this line:
(您的问题是这一行:)
if (cellno[0]=="+")
You are comparing single character, at index 0 in cellno
char array (which hopefully contains a C string) with string literal , which is a pointer (as your compler error says).
(您正在将cellno
char数组(希望包含一个C字符串)的索引0处的单个字符与字符串literal (它是一个指针)进行比较(正如您的compler错误所说)。)
You want to compare a single char, like this:
(您要比较单个字符,如下所示:)
if (cellno[0]=='+')
Note how single and double quotes have a very different meaning!
(注意单引号和双引号的含义有很大不同!)
You code has a lot of other issues, too many to list here, but that should solve the problem you are asking about.
(您的代码还有很多其他问题,在这里没有太多列出,但这应该可以解决您所要解决的问题。)
But one advice I add: do not use C strings in C++, if you can avoid it! (但是,我建议一个建议:如果可以避免,不要在C ++中使用C字符串!)
Use std::string
as soon as you are allowed to! (允许后立即使用std::string
!)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…