My goal is to copy strings_operand_table1[i] into label. I would then like to return label to my previous function that called it. How can I fix this and what better ways are there to do this?
char GetBaseDeclarationLabel(char *strings_label_table1[], char *strings_mneumonic_table1[],
char *strings_operand_table1[], int hex_address_table1[])
{
int i = 0;
int cmp_str2 = 0;
char label[20] = {0};
//int k = 0;
//printf(" i is %s \n", strings_label_table1[1]);
for(i = 0; i < 503; i++)
{
if(strings_mneumonic_table1[i] != NULL)`enter code here`
{
cmp_str2 = strcmp(strings_mneumonic_table1[i], "BASE");
if(cmp_str2 == 0)
{
//printf(" ??please?? \n");
//printf(" hex_address_table1[i] is %x \n", hex_address_table1[i]);
strcpy(label, strings_operand_table1[i]);
//label = strings_operand_table1[i];
break;
}
}
}
return label;
}
Edit:
Is this better? If I need to use pointers it seems easier to make the function void and return nothing.
void GetBaseDeclarationLabel(char *strings_label_table1[], char *strings_mneumonic_table1[],
char *strings_operand_table1[], int hex_address_table1[], char *label1)
{
int i = 0;
int cmp_str2 = 0;
//char label[20] = {0};
//int k = 0;
//printf(" i is %s \n", strings_label_table1[1]);
for(i = 0; i < 503; i++)
{
if(strings_mneumonic_table1[i] != NULL)
{
cmp_str2 = strcmp(strings_mneumonic_table1[i], "BASE");
if(cmp_str2 == 0)
{
//printf(" ??please?? \n");
//printf(" hex_address_table1[i] is %x \n", hex_address_table1[i]);
//strcpy(label, strings_operand_table1[i]);
label1 = strings_operand_table1[i];
break;
}
}
}
//return label;
}