Soundex

This is a discussion on Soundex within the C Programming forums, part of the General Programming Boards category; Hi there, I'm writing a program that converts surnames into Soundex code and I've almost finished, but having a couple ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    7

    Soundex

    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

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,550
    Move
    Code:
    int coded_name[MAXNAME];
    To the caller function; pass it to the called function (change).

    Also, change the function type to match the value being returned.

    Tim S.
    Last edited by stahta01; 11-04-2010 at 03:54 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Soundex and arrays
    By grimuth in forum C++ Programming
    Replies: 1
    Last Post: 04-04-2008, 06:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21