title: How to check for repeated characters within a string in c
body: <p>I'm trying to create a program that checks for repeated characters within the command line argument's string. The string is suppose to contain only 26 characters, and all characters have to be alphabetical. However, there cannot be any repeated characters within the string, each alphabetical character must appear only once. I figured out the first two sections of the program but I cant figure out how to check for repeated characters. I could really use some help as well as explanations.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;cs50.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  
  int main (int argc, string argv[])
  {
      if (argc != 2)
      {
          printf(&quot;Usage: ./substitution key\n&quot;);
          return 1;
      }
      else
      {
          int len = strlen(argv[1]);
          if (len != 26)
          {
              printf(&quot;Key must contain 26 characters.\n&quot;);
              return 1;
          }
          else
          {
              for (int i = 0; i &lt; len; i++)
              {
                  if (!isalpha(argv[1][i]))
                  {
                      printf(&quot;Usage: ./substitution key\n&quot;);
                      return 1;
                  }
              }
          }
      }
  }
  </code></pre>