Strlen ()
Gets the length of the string, returns the length of the string if it succeeds, or string 0 if it string is empty.
#include <stdio.h>#include<stdlib.h>#defineN 1000intCount =0;intStrlenChar*str) { intnum =0;//Define a counter while(' /'! = *str++) {num++; } returnnum;}voidTestChar*str) {printf ("The string to be tested is:%s\n", str); Count= strlen (str);//calling Functionsprintf"The length of the string entered is:%d\n\n", count);}voidMain () {CharStr1[] ="Hello world!";//such an assignment would have a ' + ' on the tail automatically Char*STR2 ="Hello world!";//such an assignment would have a ' + ' on the tail automatically Charstr3[ -] ="World hello!";//this assignment will automatically add '% ' to the remaining position. CharStr4[n] = {0}; Test (STR1); Test (STR2); Test (STR3); printf ("Please enter the array you want to test: \ n"); Gets (STR4); //This function adds the null character at the end .test (STR4);
System ("Pause");}
strcpy ()
Head.h
#include <stdio.h>#include<string.h>#define N-void strcpy1 ( Char Char const *STR);
_strcpy (). c
#include"head.h"voidStrcpy1 (Char*str_cpy,Char Const*STR)//to ensure the read-only nature of the primary array, add the "const" modifier{ while(*str! =' /') { *str_cpy = *str; str_cpy++; STR++; } *str_cpy =' /';//Add Terminator}
Main.c
#include"head.h"voidMain () {CharStr[n]; CharStr_cpy[n]; printf ("Please enter an array of the main strings you want: \ n"); scanf ("%s",&str); Strcpy1 (STR_CPY,STR); //Copyprintf"%s\n of the primary string before copying", str); printf ("%s\n of the new string after copying", str_cpy); GetChar (); GetChar ();}
PHP function Source code C write "Continuous update"