ccplusplus.com
Learn C, C++ Concepts
Monday, September 12, 2011
copy one string to another string
/****************************************************** * File : copy-one-string-to-another-string.c * Author : Saurabh Gupta * Desc : Copy one string into other without using * string function * Source : http://saurabhgupta0527.blogspot.com/ * Created : AM 09:42 12 September 2011 * Note : *****************************************************/ #include <stdio.h> #define STRING_SIZE 128 int main() { int i = 0; char strInputString[STRING_SIZE], strCopiedString[STRING_SIZE]; printf("\nInput a string \n"); scanf("%s", &strInputString); while(strInputString[i] != '\0') { strCopiedString[i] = strInputString[i]; i++; } strCopiedString[i]='\0'; printf("\nCopied string is \n%s\n\n",strCopiedString); return 0; } /* * OUTPUT * [sgupta@irhel54x64 c]$ [sgupta@rhel54x64 c]$ gcc copy-one-string-to-another-string.c -o copy-one-string-to-another-string [sgupta@rhel54x64 c]$ ./copy-one-string-to-another-string Input a string http://saurabhgupta0527.blogspot.com/ Copied string is http://saurabhgupta0527.blogspot.com/ [sgupta@rhel54x64 c]$ */
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment