Concatenate Two Strings Without Using function

#include <stdio.h>
int main()
{
    char str1[100], s2tr[100], i, j;
    printf("Enter first string: ");
    scanf("%s", str1);
    printf("Enter second string: ");
    scanf("%s", str2);
    // calculate the length of string s1
    // and store it in i  
  for(i = 0; str1[i] != '\0'; ++i);
    for(j = 0; str2[j] != '\0'; ++j, ++i)
    {
        str1[i] = str2[j];
    }
    str1[i] = '\0';
    printf("After concatenation: %s", str1);
    return 0;
}
Output:-





Disqus Comments