Advertisement
Iamtui1010

list_sub_string_of_3_strings.c

Mar 21st, 2023
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. char x[3][100] = {"abc", "de", "mnt"};
  5. FILE *fi, *fo;
  6.  
  7. void recurse(int i, char res[100])
  8. {
  9.     if (i == 3){
  10.         fprintf(fo, "%s \n", res);
  11.         return;
  12.     }
  13.     for (int j = 0; j < strlen(x[i]); ++j){
  14.         strncat(res, &x[i][j], 1);
  15.         recurse(i+1, res);
  16.         res[strlen(res)-1] = '\0';
  17.     }
  18. }
  19.  
  20. int main()
  21. {
  22.     fi = fopen("in", "r");
  23.     fclose(fi);
  24.  
  25.     fo = fopen("out", "w");
  26.     char res[100] = "";
  27.     recurse(0, res);
  28.     fclose(fo);
  29.     return 0;
  30. }
  31. // NOLINTEND
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement