字符串指针的简单使用

来源:互联网 发布:江津加工中心编程招聘 编辑:程序博客网 时间:2024/05/17 09:36
字符串指针的简单使用
#include<stdio.h>#include<malloc.h>void main(){int len;char *str=(char*)malloc(100);printf("Please input a str:\n");gets(str);len=length(str);printf("the length is %d",len);return;}int length(char *p){int n=0;while(*p!='\0'){n++;p++;}return n;} 

0 0
原创粉丝点击