I'm attempting to add a string at the end of another string when im doing a comparison. This how I would do it in java(might not be legit java code - been a while):
String input = "addl $1,%eax";
String[] registers = {"eax", "abx", "ebx", "edx"};
String s = "addl $1,%";
for (int i = 0 ; i < 4; i++) {
if (input.equals(s + registers[i])) {
printf("Match");
// write out optimized code with specified register
}
}
I'm not sure at all how to do this in C. I've tried the following but my program keeps crashing (i think because of some pointer nonsense):
...
char *in = "Hell";
char *pattern = "Hello";
const char *a[2];
a[0] = "e";
a[1] = "o";
char *result = strcat(in,a[1]);
if (strcmp(in, result) == 0) {
printf("Helloooooooooooooooo");
}
Can anyone enlighten me please how to do this kind of string manipulation in C?