[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Program Discussion :: Strings

Home > Programs > Strings

8 / 60

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: