Created
July 4, 2017 04:18
-
-
Save atpons/3bf130b220e10a9ada825457588b818b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int strLen(char *s) { | |
char *sPointer = s; | |
while (*sPointer) { | |
sPointer++; | |
} | |
return sPointer - s; | |
} | |
int strCpy(int i, char *a, char *b) { | |
a += i - 1; | |
for (; *b != '\0'; a++, b++) { | |
*a = *b; | |
} | |
*a = '\0'; | |
return 0; | |
} | |
int strIns(int i, char *buf, char *text) { | |
int n; | |
char tmpStr[255]; | |
char *tmp = tmpStr; | |
buf += i; | |
while (*buf != '\0') { | |
strCpy(strLen(buf), buf, tmp); | |
} | |
buf -= i; | |
strCpy(i, buf, text); | |
//strCpy(strLen(buf), buf, tmp); | |
return 0; | |
} | |
int main() { | |
int i; | |
char a[255], b[255]; | |
printf("Copy position > "); | |
scanf("%d", &i); | |
printf("a > "); | |
scanf("%20s", a); | |
printf("b > "); | |
scanf("%20s", b); | |
// strCpy(i, a, b); | |
strIns(i, a, b); | |
printf("%s\n", a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment