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 the difference between volatile and const volatile?

0 Answers  


how to print value of e(exp1)up to required no of digits after decimal?

1 Answers  


can we print any string in c language without using semicolon(;)(terminator) in whole program.

11 Answers  


Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings

0 Answers  


program to print upper & lower triangle of a matrix

2 Answers   TCS,






How arrays can be passed to a user defined function

0 Answers  


What is the value of c?

0 Answers  


how many keywords do C compile?

7 Answers   Microsoft, Practical Viva Questions,


What functions are in conio h?

0 Answers  


Is that possible to add pointers to each other?

0 Answers  


Find MAXIMUM of three distinct integers using a single C statement

0 Answers  


Are the expressions * ptr ++ and ++ * ptr same?

0 Answers  


Categories