Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Argument: s - pointer to a C-style string
- //Return value: A pointer to a NEW C-style string that contains the exact same characters
- //as parameter s
- char* clone(const char *s){
- int i;
- char *c=calloc(length(s),sizeof(s));
- for(i=0;i<length(s);i++){
- c[i]=s[i];
- }
- return c;
- }//clone()
- void main(){
- char *cl=clone(s1);
- printf("clone: %s\n", cl);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement