Write a program that uses a function to copy one string into another without using the strcpy() function available in the standard library of C.
C Programming Language / Function in C Language
861Program:
#include void string_copy(char [], char []); /* function prototype */ int main() { char a[100]; /*** source string ***/ char b[100]; /*** destination string ***/ printf("\n Input source string : "); scanf("%[^\n]",a); /* read input source string */ string_copy(b,a); /* function call */ printf("\n Destination string : %s\n",b); return 0; } /*** function definition ***/ void string_copy(char d[], char s[]) { int i = 0; printf("\n Source string : %s\n",s); /* copying the string */ for (i = 0; s[i] != '\0'; i++) d[i] = s[i]; d[i] = s[i]; /* Copy NUL character to destination string */ }
Output:
Input source string : atnyla Source string : atnyla Destination string : atnyla
Explanation:
None
This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS