Advertisement
rafikamal

Copying a string

Jan 23rd, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void stringCopy(char str1[], char str2[]);
  4.  
  5. int main()
  6. {
  7.     char s1[] = "BUET";
  8.     char s2[10];
  9.  
  10.     stringCopy(s1, s2);
  11.  
  12.     printf(s2);
  13.  
  14.     return 0;
  15. }
  16.  
  17. void stringCopy(char str1[], char str2[])
  18. {
  19.     int i;
  20.  
  21.     for(i = 0; str1[i] != '\0'; i++)
  22.         str2[i] = str1[i];
  23.     str2[i] = '\0';
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement