给字符串加密

字符串加密规则: a->b,b->c ... z->a  A->B ,B->C, ..... Z->A

void stringM(char *str,int count)
{
    char *p =str;
    
    for (int i = 0; i < count-1; ++i)
    {
        if (*(p+i)=='z')
        {
            *(p+i)='a';
        }
        else if (*(p+i)=='Z')
        {
            *(p+i)='A';
        }
        else
        {
            int c = *(p+i);
            
            *(p+i) = c+1;
        }
    }
    
    printf("%s",str);
    
}

int main(int argc, char const *argv[])
{
    char str[]="abcDEFzZ";
    stringM(str,sizeof(str));
    
    return 0;
}

你可能感兴趣的:(给字符串加密)