title: C - Caesar Cipher [Moving Code to Function]
body: <p>I am totally new to C programming language, so don't be too critical about my code. I found some tutorials to make Caesar Cipher encryption and decryption program, I just would like to run it from the CLI.</p>
  
  <ol>
  <li><p>I have code, but it uses global variables and doesn't use functions, i need both of them, i need to somehow move my code to function called "encryption" and another function called "decryption", this all goes to problem number 2</p></li>
  <li><p>I created encryption code, but i can't make decryption, i understand the main idea, but because i don't have function (Which i need) i can't make the decryption part of the code.</p></li>
  </ol>
  
  <p>Please help me. Here is my code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      char message[100], symbol;
      int i, key;
  
      printf("Message to encrypt: ");
      gets(message); //fgets is better
      printf("Enter key: ");
      scanf("%d", &amp;key);
  
      for(i = 0; message[i] != '\0'; ++i){
          symbol = message[i];
  
          if(symbol &gt;= 'a' &amp;&amp; symbol &lt;= 'z'){
              symbol = symbol + key;
  
              if(symbol &gt; 'z'){
                  symbol = symbol - 'z' + 'a' - 1;
              }
  
              message[i] = symbol;
          }
          else if(symbol &gt;= 'A' &amp;&amp; symbol &lt;= 'Z'){
              symbol = symbol + key;
  
              if(symbol &gt; 'Z'){
                  symbol = symbol - 'Z' + 'A' - 1;
              }
  
              message[i] = symbol;
          }
          else if(symbol &gt;= '0' &amp;&amp; symbol &lt;= '9'){
              symbol = symbol + key;
  
              if(symbol &gt; '9'){
                  symbol = symbol - '9' + '1' - 1;    
              }
  
              message[i] = symbol;
          }
      }
  
      printf("Encrypted message: %s", message);
  
      return 0;
  }
  </code></pre>
  
  <p>As i said, i need to make 2 function, one for encryption and another one for decryption, can i get some help ? </p>
  
  <p>Thank you.</p>