How to compare char* pointer with a range?

I understand you can do

char* charpointer[2];
charpointer = "12";
if (charpointer[0] == '1'){

but how can we test for a range? 0-1? so I can compare it to '12'

I wouldn't want to do charpointer[0] == '1' && charpointer[1] == '2' though.
Use a C library function - strcmp

There are other versions which are safer to use though.

If using C++ and you can get away with not using char arrays - that is no specific need to use them (like having to interface with an API), then use the STL string class.

C strings (char arrays)

C++ string class:

Good Luck!!

I found this, there are others to google if interested:
Last edited on
Topic archived. No new replies allowed.