问题
I am reading a file that has some data in it. The data is not uniform. But once in a while there might be a line that have a file name and SHA1 sum value in it. I read the data line by line, and then when there is a line with SHA1 sum value, I use strtok, to get data in tokens. And I get SHA1 sum in a variable (e.g: char *hash).
Later in the program, I re-run SHA1 on the same file to get the hash sum (in a variable such as unsigned char hash[20]). Now I want to compare these to values, but I don't know how to approach that. Should I convert unsigned char array to char* or should I convert char* to unsigned char? or can I compare them without converting? And if conversion is needed, how to do this conversion. I found that sprintf can be used for that, but couldn't do it.
EDIT: I realized that this problem was part of another problem I had. I have posted that question here with code.
来源:https://stackoverflow.com/questions/29405538/converting-char-to-unsigned-char-array-c