Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

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?...

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;

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question