Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get element type in C++?

I am a beginner at programming in C++, I would like to ask you, what is the algorithm/ way to see what kind of element is the following in a char / string.

For example, if I have

char b[]="Ab 3";

and the index, let's say "i" is

i=2;

this means that on i=3 there is '3'. My question: Does there exist an algorithm, which tells me, if I am on index 2, what type of element is on index 3? In our case an 'int'.

Thank you very much!

like image 898
AdamK Avatar asked Jan 22 '26 15:01

AdamK


1 Answers

The type for any element in a char array will always be char. You can, however, check if the char is a digit with isdigit(ch).

like image 145
tpatja Avatar answered Jan 24 '26 06:01

tpatja