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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 3 types of structures?

580


How many types of operators are there in c?

628


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2208


Why is c called c?

640


Which header file is essential for using strcmp function?

951






Do you have any idea how to compare array with pointer in c?

615


Explain spaghetti programming?

689


Why is c so important?

606


Explain the difference between ++u and u++?

649


What is the deal on sprintf_s return value?

649


What is the difference between far and near ?

698


what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above

689


What is null pointer constant?

603


How do I get a null pointer in my programs?

629


What is the difference between typedef and #define?

552