### Difference between two string.

I want to compare two string, and want to see differeince in int form. For example,

 ``12`` ``````string first_string="0002AE1"; string second_string="0002AE2";``````

How can i calculate difference between two string? It is obvious difference between above two string is 1/-1, but difference would be 1.
Do you want to find the differences between two strings, as the title of your post suggests, or do you want to find the difference between two hex values, as your example suggests?
Yes, it would be better if you explain both. Is the result same for the both cases?
No, the result is drastically different, and the two things are completely unrelated and on opposite sides of the world from each other.

Example of difference between two strings:

Example of difference between two hex numbers:
http://www.wolframalpha.com/input/?i=abs%280x1A+-+0x2B%29
I need concrete c++ function which can calculate the difference.
You still have not specified which kind of difference you want.
Hex value difference. Thnx in advance.
 ``123`` ``````int a, b; std::cin >> std::hex >> a >> b; std::cout << std::hex << std::abs(b-a) << std::endl;``````
Working example: http://ideone.com/92eeTP
Thnx.
Topic archived. No new replies allowed.