Computer Scientists are Pretty Pessimistic

Thursday 1 October 2015

WAP to copy a string into another string.

CODE ::

#include <stdio.h>
#include <string.h>
int main ()
{
    int i,j,k;
    char a[100],b[100],c[100];
    printf("Enter a string: ");
    gets(a);
    printf("Enter another string: ");
    gets(b);
    for(i=0;i<a[i];i++)
    {
        c[i]=a[i];
    }
    c[i++]=' ';
    for(j=i,k=0;k<b[k];k++,j++)
    {
        c[j]=b[k];
    }
    c[j]='\0';
    puts(c);
    return 0;
}

3 comments:

  1. what's the purpose of this code...very confusing...Just input one string man not two..: (

    ReplyDelete
    Replies
    1. as a professional programmer you have to do all thing as user defined, and this code is now right :)

      Delete
  2. where is c[?] ?????.Make this code correct.. :(

    ReplyDelete