Two string operation functions.

zhaozj2021-02-16  54

/ *! Brief replicates the back part of the string

Write functions Strmcpy (s, t, m), copy the string from all characters starting from the Mth characters into the string S. N Difficult Coefficient: Simple Param [In] Source Source string. Read-only param [in] de P. Param [in] NStart starts Copy bug- # unscruted from NStart characters to copy bug- # uncomfortable Strlen (Source)

pre source is zero ending && strlen (source)> nStart && sizeof (dest)> sizeof (source) post dest is zero ending && strcmp (dest, source nStart) == 0 * / void LeftSubStr (char * source, char * DEST, INT NSTART) {char * p = source nStart; char * q = dest; while (* q = * p );}

// 4. Write a function, enter a string, have a number and non-digital characters, and the continuous number is used as an integer, and store it in the array A, and how many integers are statistics.

// If you don't use the library: int isdigit (int C) {return! (C <'0' || c> '9');}

Int atoi (char * str) {char * p = str; int sum = * p - '0'; while (isdigit (* p)) {SUM = SUM * 10 (* P - '0'); }

Return Sum;

INT FINDDIGITAL (CHAR * STR, INT BUF [], INT NLEN) {char * p = str; INT i; for (i = 0; i

#include

INT main () {Int a [10]; int Len = Finddigital ("- 11, 2", A, 10); Printf ("% D,% D,% D", Len, A [0], A [1]); return 0;}

转载请注明原文地址:https://www.9cbs.com/read-15617.html

New Post(0)