Syntax: Mid (char str[],int start,int Len,char strback[])
Parameters:
Str[]: Target string for operation
Start: Starts with the beginning of the first string and intercepts the Len-length characters
Len: Starts with the beginning of the first string and intercepts the Len-length characters
Strback[]: truncated to the character
return value:
0: Out of string length, intercept failed; 1: Intercept Successful
#include <stdio.h> #include <string.h>int mid (char str[],int start,int Len,char strback[]); int main () {// Char a[]= "I have a Dream";//Initialize the character array without specifying its size char Str[100];char newstr[100];//just purely stating that a character array variable would have to specify a size gets (str); In the VS2008 there will be a warning (gets unsafe. ), change gets to gets_s will not appear warning prompt int m=mid (STR,2,4,NEWSTR), if (m) {printf ("%s\n", newstr),//output string, with the same effect//puts (NEWSTR);} Else{printf ("Out of string length \ n"), or/n will wrap puts ("Out of string Length"),//output will wrap}return 0 after playing string;} int mid (char str[],int start,int Len,char strback[]) {int L,i,k=0;l=strlen (str), if (start+len>l) return 0;for (I=start ; i<start+len;i++) {strback[k]=str[i];k++;} strback[k]= ' + ';//key step return 1;}
String processing of the ACM Classic algorithm: string interception