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

Why we use break in c?

0 Answers  


What is volatile keyword in c?

0 Answers  


What are the types of bitwise operator?

0 Answers  


What is double pointer in c?

0 Answers  


How can I get random integers in a certain range?

0 Answers  






define c

6 Answers   HCL, TCS,


Write the Program to reverse a string using pointers.

0 Answers   InterGraph,


Can we initialize extern variable in c?

0 Answers  


List the difference between a While & Do While loops?

0 Answers   Accenture,


Explain what are the different file extensions involved when programming in c?

0 Answers  


how can we use static and extern?and where can we use this?

3 Answers   Excel,


What is static function in c?

0 Answers  


Categories