Created
March 1, 2015 08:17
-
-
Save WenhaoWu/82da1a6072b88049169b to your computer and use it in GitHub Desktop.
lab28
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> | |
#include <string.h> | |
void app (char*, char*, int); | |
int main(){ | |
char s1[40]="", s2[40]= ""; | |
strcpy(s1, "012345678901234567890123456789012345"); | |
strcpy(s2, "abcdefghijklmn"); | |
printf("%s\n", s1); | |
app(s1,s2,40); | |
printf("%s\n", s1); | |
return 0; | |
} | |
void app (char *s1, char *s2, int count){ | |
//This while loop is to make the pointer point to the final element of s1 | |
while(*s1){ | |
s1++; | |
} | |
while(*s2){ | |
if(s1[39]!=''){ | |
break; | |
} | |
*s1 = *s2; | |
s2++; | |
s1++; | |
} | |
*s1 = '\0'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment