利用指针,编写交换两个整型变量值的函数,用于实现输入的3个整数按照从大到小或者从小到大的顺序输出。

编写一函数len,求一个字符串的长度。要求用字符指针实现。在主函数中输入字符串,调用该len函数后输出其长度。
期末了,有很多不会的,想找一个师傅问问题,会请喝奶茶,谢谢!


void swap(int *a, int *b){
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}


#include <stdio.h>
int len(char *p);
int main()
{
    int a,b,c;
    char str[25];
    gets(str);
    printf("%d",len(str));

}
int len(char *p){
    int a = 0;
    while(*p != '\0'){
        a ++;
        p ++;
    }
    return a;
}