C 练习实例70
C 语言教程
· 2019-02-22 11:29:33
题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。
程序分析:无。
实例
// Created by www.codercto.com on 15/11/9.
// Copyright © 2015年 码农教程. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
int main()
{
int len;
char str[20];
printf("请输入字符串:\n");
scanf("%s",str);
len=length(str);
printf("字符串有 %d 个字符。",len);
}
//求字符串长度
int length(char *s)
{
int i=0;
while(*s!='\0')
{
i++;
s++;
}
return i;
}
以上程序执行输出结果为:
请输入字符串: www.codercto.com 字符串有 14 个字符。
点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html
Mastering JavaServer Faces
Bill Dudney、Jonathan Lehr、Bill Willis、LeRoy Mattingly / Wiley / 2004-6-7 / USD 40.00
Harness the power of JavaServer Faces to create your own server-side user interfaces for the Web This innovative book arms you with the tools to utilize JavaServer Faces (JSF), a new standard that wi......一起来看看 《Mastering JavaServer Faces》 这本书的介绍吧!
RGB CMYK 转换工具
RGB CMYK 互转工具
HSV CMYK 转换工具
HSV CMYK互换工具