strappnd.c

来自「This is code tutorial for image processi」· C语言 代码 · 共 50 行

C
50
字号

/*
 * NAME: append_string (string1, string2)
 *
 * FUNCTION: Appends the contents of string1 to the contents
 *           of string2.
 *
 * EXAMPLE:  string1    string2 before   string2 after
 *           " there!"      "Hello"      "Hello there!"
 *
 *           append_string (string1, string2);
 *
 * VARIABLES USED:  string1: string to append.
 *                  string2: string being appended to.
 *                  index1:  index into string1.
 *                  index2:  index into string2.
 *
 * PSEUDO CODE:  initialize index2 to 0
 *
 *               while (string2[index2] is not NULL)
 *                  increment index2  -- to find the end of string2
 *
 *               initialize index1 to 0
 *
 *               while (string2[index2] is assigned the letter in
 *                      string1[index1] and the letter is not NULL)
 *                  increment index1 and index2
 *
 */

#include "cips.h"

 append_string (string1, string2)
   char string1[];		  /* string to append */
   char string2[];                 /* string appended to */
  {
   int index1; 	  /* current location in string1 */
   int index2;    /* current location in string2 */

   /* find the end of string2 */

   for (index2 = 0; string2[index2] != '\0'; index2++)
     ;

   /* append string1 to string2 */

   for (index1 = 0;(string2[index2] = string1[index1])!= '\0'; ++index1)
       ++index2;   /* also increment string2 */
  }

⌨️ 快捷键说明

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