⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 len.c

📁 linux下的C语言开发
💻 C
字号:
/******************************************************** * Question:						* *	Why does this program always report the length	* *	of any string as 0?				* *							* * A sample "main" has been provided.  It will ask 	* * for a string and then print the length.		* ********************************************************/#include <stdio.h>/******************************************************** * length -- compute the length of a string             * *                                                      * * Parameters                                           * *      string -- the string whose length we want       * *                                                      * * Returns                                              * *      the length of the string                        * ********************************************************/int  length(char string[]){    int             index;      /* index into the string */    /*     * Loop until we reach the end of string character     */    for (index = 0; string[index] != '\0'; ++index)        /* do nothing */    return (index);}int main(){     char line[100];	/* Input line from user */     while (1) {        printf("Enter line:");        fgets(line, sizeof(line), stdin);	printf("Length (including newline) is: %d\n", length(line));    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -