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

📄 acronym.c

📁 c语言开发方面的经典问题,包括源代码.c语言开发所要注意的问题,以及在嵌入式等各方面的应用
💻 C
字号:
/* * File: acronym.c * --------------- * Implements and tests the Acronym function. */#include <stdio.h>#include "genlib.h"#include "simpio.h"#include "strlib.h"/* Function prototypes */string Acronym(string str);/* Main program */main(){    string str;    printf("This program generates acronyms.\n");    printf("Indicate end of input with a blank line.\n");    while (TRUE) {        printf("String: ");        str = GetLine();        if (StringEqual(str, "")) break;        printf("The acronym is %s.\n", Acronym(str));    }}/* * Function: Acronym * Usage: acronym = Acronym(str); * ------------------------------ * Takes a string consisting of a sequence of words and returns * the acronym formed by taking the initial letter of each word. * The program operates by finding each space in the word and * then concatenating the following letter onto the acronym so * far.  At the beginning, the acronym is set to be the first * character in the string. */string Acronym(string str){    string acronym;    int pos;    acronym = CharToString(IthChar(str, 0));    pos = 0;    while (TRUE) {        pos = FindChar(' ', str, pos + 1);        if (pos == -1) break;        acronym = Concat(acronym,                         CharToString(IthChar(str, pos + 1)));    }    return (acronym);}

⌨️ 快捷键说明

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