Removing consecutive occurence of same characters

Given a string, replace all the consecutively occurring characters by a single, same character.
For example: If the given string is "aabbcc", after replacing consecutively occurring characters{aa, bb,cc}, by the single same character {a,b,c}the final string will be "abc"
 

Implementation:



#include <stdio.h>
#define MAX 100000
int main()
{
      char f[MAX],s[MAX],k;
      int j,t,i;
      scanf("%d",&t);
      while(t--)
      {
           j=0;
           scanf("%s",s);
           k=s[0];
           f[j]=k;
           j++;
           for(i=1;s[i]!='\0';i++)
           {
                if(k==s[i])
                {
                     continue;
                }
                else
                {
                     f[j]=s[i];
                     k=s[i];
                     j++;
                }
           }
           f[j]='\0';
           printf("%s\n",f);
      }
return 0;
}