Using C: compile a function that extracts a substring from a string.
# Include <stdio. h> # include <stdlib. h> # include <string. h> int substr (char dst [], char src [], int start, int len) {int I; for (I = 0; I <len; I ++) {dst [I] = src [start-1]; start ++;} dst [I] = 0; printf ("the copied substring is :"); for (I = 0; I <strlen (dst); I ++) printf ("% c", dst [I]); return (strlen (dst ));} int main () {char dstr [50], src [50]; int star, len, I = 0; int flag = 1; printf ("\ n please input a string, length less than 50, src =: "); while (flag) {src [I] = getchar (); if (src [I] = '\ n ') flag = 0; I ++;} printf ("\ n: Replace the nth character:"); scanf ("% d", & star ); printf ("\ n the substring for which you want to copy:"); scanf ("% d", & len ); printf ("\ n substring length: % d \ n", substr (dstr, src, star, len); system ("pause"); return 0 ;}