Create a String whose consecutive characters are not same

Given a string containing characters A and B only, you have to change it into a string as in the following example.

For Example:
If a given string is "ABAA", the output string should be "ABA" 
To do this, you are allowed to delete the characters in the string. Now, Find the minimum number of required deletions.
See some more examples to understand better.

AAAA              =>  A               3 deletions
BBBBB            =>  B               4 deletions
ABABABAB      => ABABABAB   0 deletions
BABABA          => BABABA      0 deletions
AAABBB          => AB              4 deletions


Implementation:


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
      int T,i;
      char Sa[99999];
      char Tmp;
      int delcount=0;
      scanf("%d",&T);
      while(T>0)
      {
           delcount=0;
           scanf("%s",Sa);
           Tmp=Sa[0];
           for(i=1;Sa[i]!='\0';i++)
           {
                if(Tmp==Sa[i])
                delcount++;
                else
                {
                     Tmp=Sa[i];
                }
           }
           printf("%d\n",delcount);
           T--;
      }
      return 0;
}