I have the code below, and I'm trying to compare the content of arrayx with argv[2] (user input argument upon execution), however even when the argv[2] matches with the content of arrayx, it bypasses to the else statement.
If I try to use:
strcpy(arg3, "inputstring" );
Then it works.
Also, if I try to printf(%s, arrayx), it prints out the correct string.
Any idea why it does not work when I try to use the arrayx variable on strcmp ?
float float_arrayx[] = {
0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a
};
unsigned char arrayx[sizeof(float_arrayx) / sizeof(*float_arrayx)];
for (size_t j = 0; j < sizeof(arrayx) / sizeof(*arrayx); j++) {
arrayx[j] = (unsigned char)float_arrayx[j];
}
if (argc == 3 && (strcmp(argv[1], arg_help))) {
char arg3[100];
char arg2[32];
strcpy(arg3, arrayx );
strcpy(arg2, "-exec");
if(!strcmp(argv[1], arg2)) {
if(!strcmp(argv[2], arg3))
{
printf("\nDO SOMETHING....\n");