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

All technical questions

0 Answers   TCS,


Process by which one bit pattern in to another by bit wise operation is?

0 Answers   InterGraph,


typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none

0 Answers  


Why header file is used in c?

0 Answers  


what is the code to display color fonts in the output?

1 Answers  


What are the advantages of the functions?

0 Answers  


what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555

0 Answers   Wipro,


What is pointer to pointer in c with example?

0 Answers  


1. What will be the output of the following programs. a) #include <stdio.h> Main() { Int x=4; While(x==1) { X=x-1; Printf(“%d”,x); --x; } }

7 Answers   CSC,


Differentiate between ordinary variable and pointer in c.

0 Answers  


where do we use structure pointer?

1 Answers  


what are bit fields? What is the use of bit fields in a structure declaration?

0 Answers   Flextronics, TISL, Virtusa,


Categories