Skip to content

Instantly share code, notes, and snippets.

@dd1994
Created May 12, 2014 11:50
Show Gist options
  • Select an option

  • Save dd1994/d115bdd8f719dbdae32e to your computer and use it in GitHub Desktop.

Select an option

Save dd1994/d115bdd8f719dbdae32e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
void mcopy(char *, char *, int);
int main(void)
{
char a[80], b[80];
int m;
while(scanf("%d", &m) != EOF) {
gets(a);
mcopy(a, b, m + 1);
printf("%s\n", b);
}
return 0;
}
void mcopy(char *src, char *dst, int m)
{
int i, j;
for (j = 0, i = m - 1; src[i] != '\0'; ++i, ++j)
{
dst[j] = src[i];
}
dst[j] = '\0';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment