title: distance between two pointers in C
body: <p>I have a function that it is supposed to read a string (only with numbers in it) and return the biggest sequence that doenst have repeated numbers.
  for example:
  12345267890</p>
  
  <p>it should return: 345267890</p>
  
  <p>i've experimented the code manually and I believe it should work. but when I run it, and when it reaches this line <code>i=(strchr(v+i, *(v+j)))-v;</code> instead of getting the distance between the pointers I get something like -1046583. can I do this?</p>
  
  <pre><code>char* bigSeq(char *v){
  
      int i, j;
      char *aux, *bgst;
      aux=(char*) malloc(10*sizeof(char));
      bgst=(char*) malloc(10*sizeof(char));
      for(i=0;i&lt;strlen(v);i++){
          for(j=0;j&lt;strlen(v+i);j++){
              if(strchr(v+i, *(v+j)) != (v+j)){
                  if(strlen(strncpy(aux, (v+i),j)) &gt; strlen(bgst))
                      strncpy(bgst, (v+i),j);
                  i=(strchr(v+i, *(v+j)))-v;
                  break;
              }
          }
      }
      return bgst;
  }
  </code></pre>