write a string copy function routine?

Answers were Sorted based on User's Feedback



write a string copy function routine?..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void str_cpy(const char *,const char *);
void main()
{
char a[20],b[20];
printf("enter the string for a[] :");
gets(a);
str_cpy(a,b);
printf("\nthe string for b[] is : ");
puts(b);
getch();
}

void str_cpy(const char *a,const char *b)
{
while((*a)^'\0')
{
*b=*a;
*a++;
*b++;
}
*b='\0';
}


thank u

Is This Answer Correct ?    5 Yes 1 No

write a string copy function routine?..

Answer / ragu

if we compile in turbo c its showing error like this
in that above code we cant modify a const object in function str_cpy(const char *a,const char *b)

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

WHAT IS ABSTRACT DATA TYPE

4 Answers   Wipro,


how many keywords do C compile?

7 Answers   Microsoft, Practical Viva Questions,


nic scientist exam

1 Answers   NIC,


struct abc { unsigned int a; char b; float r; }; struct xyz { int u; struct abc tt; }ww; ww = (struct xyz*)malloc(sizeof(struct xyz)); will the memory be allocated for the inner structure also?

1 Answers   Wipro,


How does normalization of huge pointer works?

0 Answers  


Write a c program using for loop in switch case?

1 Answers   Infosys,


What is difference between far and near pointers?

0 Answers  


Explain how can a program be made to print the name of a source file where an error occurs?

0 Answers  


Write a C program to check a number even or odd, without using any relational, arithmetic operator and any loops.

1 Answers  


Find if a number is power of two or not?

1 Answers  


write aprogram for There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.

1 Answers   iGate, Shashi, Source Bits, Subex,


what is difference between array of characters and string

18 Answers   Accenture, Nest,


Categories