title: App that prints everything after the last occurrence of :: in a string ( C )
body: <p>I'm trying to write an app that prints everything after the last occurrence of 2 colons &quot;::&quot;, so if it's 3 &quot;:::&quot; it won't count. if the string is &quot;He::ll::o&quot; it should print out &quot;o&quot; and if it's &quot;12312::233&quot; it should print out &quot;233&quot;, I have to use <code>char* extract(char* input);</code> and a Pointer function <code>void extract2(char* input, char** output)</code> I just started learning <code>C</code> today and I'm a bit overwhelmed. I'm also not allowed to import libraries. this is what I have so far. any help is appreciated.</p>
  <pre><code>
  int isCH(char c) {
    return (c != ':' &amp;&amp; c != '\0');
  }
  
  char *extract(char *input){
      int state = 1;
      char *doubleColon;
      
      while(1){
          switch(state){
              case 1:
                  if(isCH(*input))
                  state = 1;
                  if(*input == '\0')
                  state = 2;
                  if(*input == ':') // first colon
                  state = 3;
              break;
              case 2:
                  return doubleColon;
              break;
              case 3:
                  if(isCH(*input))
                  state = 1;
                  if(*input == '\0')
                  state = 2;
                  if(*input == ':'){ // second colon
                  state = 4;
                  doubleColon = input;
                  }
              break;
              case 4:
                  if(isCH(*input))
                  state = 1;
                  if(*input == '\0')
                  state = 2;
                  if(*input == ':')
                  state = 1;
                  break;
          }
          input++;
      }
  }
  
  int main() {
      printf(&quot;End of String: %c&quot;, *extract(&quot;Ha::ll::o&quot;));
  } 
  </code></pre>