idastan97

CSCI151 L25 P1

Nov 9th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. char* stringCopy(char *fromStr) {
  4.     char *toStr=(char*)malloc(20*sizeof(char));
  5.     int i=0;
  6.     while (*fromStr!='\0'){
  7.         toStr[i]=*fromStr;
  8.         i++;
  9.         fromStr++;
  10.     }
  11.     toStr[i]='\0';
  12.     return toStr;
  13. }
  14.  
  15. int main(void) {
  16.     char dd[]="fdfsf";
  17.     char *p=stringCopy(dd);
  18.     printf("%s", p);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment