Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.m
- // lab10progA
- //
- // Created by Alex Donofrio on 3/30/15.
- // Copyright (c) 2015 Alex Donofrio. All rights reserved.
- //
- #include <stdio.h>
- #include <string.h>
- void my_strcpy (char dest[],const char src[]);
- int main() {
- char str1[31];
- char str2[31];
- printf("Enter string of lenght at most 30: ");
- scanf("%s",str1);
- my_strcpy(str2, str1);
- my_strcpy(str1,"You entered: ");
- printf("%s %s\n",str1, str2);
- //preconditions: src is terminated by '\0'
- // dest is big enough to hold src
- //postconditions: dest contains src and is terminated by '\0'
- //
- return 0;
- }
- void my_strcpy (char dest[],const char src[]){
- int i=0;
- while(src[i]!='\0'){
- dest[i]=src[i];
- i++;
- }
- dest[i]='\0';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement