#include <stdio.h>
#include <stdlib.h>
void main()
{
    char a[30],b[30],i;
    printf("enter the a: ");
    gets(a);

    for(i=0;a[i]!='\0';i++)
{
        b[i]=a[i];

}

    printf("%d",b);
}

it produces a wrong output

Why didn't you use strcpy as stated in your title?
Avoid using gets() try fgets instead, article explaining why.
At line 15 your trying to output an integer even though "b" is a character array

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.