Quesion with char

Hey guys ny one knows how to take the characters of a character array as groups.
eg: char ch[]="987652345v" // assume this is an id no

So what I want is take the first two numbers (98) to one char variable or int or any kind of variable so I can use it for calculations or .......


Any suggestion ?

Thank You ..!!!!!!!
You should not use char arrays/C strings.

1
2
3
string str="987652345v";
string firstTwo=str.substr(0,2);
cout << firstTwo;

See here:
http://www.cplusplus.com/reference/string/string/
Last edited on
ok Thanks a lot ,.. for that

could you please tell me the real difference between char and string ?
std::string is a C++ type for handling strings. It manages memory automatically and provides various useful functions, as you can see in the reference.
There's generally no good reason to use char arrays in C++.
hm Great .
Thanks ..!!
Topic archived. No new replies allowed.