I am designing my own algorithm to check if 2 codes are similar or identical?

How do pre-exsting softwares do this?
What logic do they use?
Are there different levels of testing for this?
please give detailed answers

CLOSED DUE TO DOUBLE POST, SEE http://www.daniweb.com/software-development/cpp/threads/420816/how-to-check-2-codes-are-similar-or-identical