Code copy string in C
#include <stdio.h>
char *copyString(char *,char *);
void main()
{
char *first = (char *)calloc(sizeof(char),10);
char *second = (char *)calloc(sizeof(char),10);
printf("Enter first string:\t");
scanf("%s",first);
printf("%s",copyString(first,second));
}
char *copyString(char *a,char *b)
{
int i=0;
while(*(a+i)!='\0')
{
*(b+i)=*(a+i);
i++;
}
*(b+i)='\0';
return b;
}
Case 1:
Input : Hello
Output : Hello
Case 2:
Input : Hello World
Output : Hello
So, my question is whether space is considered as newline/null ?? Because, in second case, it shows like this..