write a program to copy a string without using a string?

Answers were Sorted based on User's Feedback



write a program to copy a string without using a string?..

Answer / balaji ganesh

#include<stdio.h>
#include<string.h>
void main()
{
char a[50],b[50];
int i,n=0;
clrscr();
printf("enter a string:");
while((a[n]=getchar())!='\n')
{
b[n]=a[n++];
}
for(i=0;i<n;i++)
printf("%c",b[i]);
getch();
}

Is This Answer Correct ?    5 Yes 2 No

write a program to copy a string without using a string?..

Answer / j j ramesh

void main()
{
char str1[100],str2[100];
printf("ENTER THE STRING :");
gets(str1);
for(i=0;str1[i];i++)
str2[i] = str1[i]l
pritf("COPIED : %s",str2);
}

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More C Interview Questions

What is Conio.h ?

2 Answers   TCS,


Explain b+ tree?

0 Answers  


what is memory leak?

3 Answers  


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

0 Answers   CSC, Wipro,


write an algorithm to display a square matrix.

0 Answers  






What are linker error?

0 Answers  


Explain what are the __date__ and __time__ preprocessor commands?

0 Answers  


What is the difference between char a[] = "string"; and char *p = "string"; ?

14 Answers   Adobe, Honeywell, TCS,


What are two dimensional arrays alternatively called as?

0 Answers  


What are register variables in c?

0 Answers  


What is #include stdio h and #include conio h?

0 Answers  


can anyone suggest some site name..where i can get some good data structure puzzles???

0 Answers  


Categories