Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
Practice Tech Mahindra Essay Topics

Program Discussion :: Strings

Home > Programs > Strings

43 / 59

Write a function to implement strncpy using recursion.

Answer:

#include

#include
int main()
{
    char s1[100],s2[100];
    int n;
    printf("Enter the string: ");
    scanf("%s",s1);
    printf("Enter the no. of characters to be copied: ");
    scanf("%d",&n);
    printf("String 1: %s ",s1);
    printf("String 2 after performing strncpy(): %s",strncpy(s2,s1,n));
    return 0;
}

Asked In :: Global Edge

Post Your Answer Here:

Language:

Post Your Reply Here: