A
A
Alexander2019-03-10 17:15:44
C++ / C#
Alexander, 2019-03-10 17:15:44

Why did the Comparison between pointer and integer error occur?

Hi everyone! I'm learning c++builder
I got this error:
[bcc32c Error] bcbl.cpp(47): comparison between pointer and integer ('int' and 'const char *')
Code:

String str = "text,text";
if (str[4] == ",")  // ошибка

what am I wrong and how to compare correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
@
@pestunov, 2019-03-10
_

Str[4] == ','
The character must be written in apostrophes, not quotes. Strings are written in quotes, for example, str == "abcde".

A
Alexander, 2019-03-10
@braxi

Problem solved, instead of ',' nuno ','

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question