To C Programming And Would Like To Ask Why I Could Not Use The For Loop To Conca

I am new to c programming and would like to ask why I could not use the for loop to concatenate , for example, N strings (N to be input by me) into one string? Please help if you could. Thank you very much.

Input: The number of inputs n, then n input chars

Output: concatenated chars

: 3 welcome to hku : welcometohku

The codes I have written are as follow:

#include <stdio.h>

#include <string.h>

int main(){

      int num;  /* array with 50 elements */

      /* read array */

      scanf(“%d”, &num);

      for (int i = 0; i < num; i++){

        char iarray[100];

        scanf(“%s”, iarray);


       /* print array elements in reverse order */

      for (int i = 0; i < num; i++){

          strcat(0array, iarray);


return 0;


Leave a Reply

Your email address will not be published. Required fields are marked *