I need a function in cuda that recieves an array of chars and if they match, the function returns a value, but when i test this code, always return 0, like none of these con
How about this:
__device__ int my_strcmp(const char *str_a, const char *str_b, unsigned len = 256){
int match = 0;
unsigned i = 0;
unsigned done = 0;
while ((i < len) && (match == 0) && !done){
if ((str_a[i] == 0) || (str_b[i] == 0)) done = 1;
else if (str_a[i] != str_b[i]){
match = i+1;
if ((int)str_a[i] - (int)str_b[i]) < 0) match = 0 - (i + 1);}
i++;}
return match;
}