Here's my version of the code...I'm only guessing on what you're trying to accomplish. Perhaps you should clarify:
Let's address some errors first:
1) wgt_ptr-- should be *wgt_ptr-- since you want the value of it and not the address where it's pointing to. Also when you initialized it it should be: *wgt_ptr = &weight....
2) if( tot != code[ strlen( code ) ] )
Your string has 5 characters so you will get code[5] but the 5th index contains the '\0' character. Change it to strlen(code) - 1 if you really wanted the last character in your string.
3) I don't understand your for loop. It keeps overwriting the old tot value everytime it loops. So why don't you run it once with this:
tot = (code[strlen(code)-2] - '0') * (weight[0] - '0');
It does the exact same thing as your for loop.
Code:
#include <stdio.h>
#include <string.h>
#define MODULUS 11
int main()
{
char code[] = "24686", weight[] = "23456", *wgt_ptr = &weight[ ( strlen( code ) - 2) ];
int loop, tot = 0;
for( loop = 0; loop < ( strlen( code ) ) - 1; loop++ )
{
tot = ( ( code[loop] - '0') * ( ( *wgt_ptr-- ) - '0' ) );
}
tot = MODULUS - ( tot % MODULUS );
if( tot != code[ strlen( code )-1 ] - '0')
printf("Invalid code");
return 0;
}
Again, I'm not sure what you're doing. Hope this gets you on the right track though.
EDIT - yeah hammer, there was more