Can anyone help with the following problem? I am trying to fix a problem in some code and, being a complete novice with
no C programming experience I am probably missing the obvious. Below is the section that is causing the problem; the code compiles OK but when you run the program it is baulking at the
for statement and skipping the rest of the code.
Code:
/* output the predefined special function registers */
sp = predef_sfr;
for(i = 0; i < sizeof(predef_sfr) / sizeof(PREDEF_SFR); ++i)
{ memset(outp, ' ', 79);
if((sts = format_addr20(sp->sfr_addr, &outp[COL_PC])) < 0) /* put value in 1st 5 chars */
return(sts);
memcpy(&outp[20], sp->sfr_name, strlen(sp->sfr_name) );
memcpy(&outp[54], "equ", 3); /* put SFR name in output */
outp[60] = '$';
if((sts = format_addr20(sp->sfr_addr, &outp[61])) < 0)
return(sts);
outp[66] = '\0'; /* pull null termination in output */
output_line(file_ptr_output, showhex, spacer_line, outp);
++sp;
}
I think it is the second expression that is the cause of the problem where the loop should be comparing the loop counter with the total length of a structure. I'm sure that more info will be required to help understand the code snippet so just ask and I'll try to answer.
Thanks in advance.