a program in c++ which take some string from user and generate a unique code against it
Thats called hashing. You could do something like this :
string str = "abc";
unsigned long long hashCode = str[0]*1 + str[1]*2 + str[2]*3;
Basically, you are multiplying the value at the string's position by its index plus 1.
If you want something better, google the term hash function.