Hi there,
I'm writing a program that converts surnames into Soundex code and I've almost finished, but having a couple of problems with one of my functions. I keep getting two errors saying:
warning: return makes integer from pointer without a cast
warning: function returns address of local variable
Here's my code. I'd really appreciate some help!!
Code:
int change(int *c)
{
int coded_name[MAXNAME];
int *p = coded_name;
int cnt;
while (cnt < CODELEN) {
for ( ; *c != '\0'; c++) {
if(*p++ == 'b' || *p++ == 'p' || *p++ == 'f' || *p++ == 'v') {
*p++ = 1;
}
else if(*p++ == 'c' || *p++ == 's' || *p++ == 'k' ||
*p++ == 'g' || *p++ == 'j' || *p++ == 'q' ||
*p++ == 'x' || *p++ == 'z') {
*p++ = 2;
}
else if(*p++ == 'd' || *p++ == 't') {
*p++ = 3;
}
else if(*p++ == 'l') {
*p++ = 4;
}
else if(*p++ == 'm' || *p++ == 'n') {
*p++ = 5;
}
else if(*p++ == 'r') {
*p++ = 6;
}
else {
*p++ = 0;
}
}
}
return coded_name;
}
Thanks