Advertisement
Guest User

Swaggy P

a guest
Mar 30th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //
  2. // main.m
  3. // lab10progA
  4. //
  5. // Created by Alex Donofrio on 3/30/15.
  6. // Copyright (c) 2015 Alex Donofrio. All rights reserved.
  7. //
  8.  
  9. #include <stdio.h>
  10. #include <string.h>
  11.  
  12. void my_strcpy (char dest[],const char src[]);
  13.  
  14. int main() {
  15. char str1[31];
  16. char str2[31];
  17.  
  18. printf("Enter string of lenght at most 30: ");
  19. scanf("%s",str1);
  20. my_strcpy(str2, str1);
  21. my_strcpy(str1,"You entered: ");
  22. printf("%s %s\n",str1, str2);
  23.  
  24.  
  25. //preconditions: src is terminated by '\0'
  26. // dest is big enough to hold src
  27. //postconditions: dest contains src and is terminated by '\0'
  28. //
  29.  
  30. return 0;
  31. }
  32.  
  33. void my_strcpy (char dest[],const char src[]){
  34. int i=0;
  35. while(src[i]!='\0'){
  36. dest[i]=src[i];
  37. i++;
  38. }
  39. dest[i]='\0';
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement