C- strncpy():           The general
format of strncpy() function is:
Syntax:           strncpy(targetstring
, sourcestring , n);
            Where, n is
an integer argument.  Function copies
atmost n characters of source string to target string.
/* EXAMPLE PROGRAM */
#include<string.h>
main()
{
            char
str1[50],str2[50];
            clrscr();
            printf("\nEnter
string 1:");
            gets(str1);
            strncpy(str2,str1,3);
            str2[3]='\0';
            printf("\nRESULT
1:");
            puts(str1);
            printf("\nRESULT
2:");
            puts(str2);
}
 

 
 
 
 
 
 
No comments:
Post a Comment