Concatena Stringa K volte



    This code creates a string of characters and stores it in a memory buffer. The product() function reads the string from the buffer and prints it out.

    Shortcut: create

    #define _GNU_SOURCE 
    #include <stdio.h> 
    #include <stdlib.h> 
    #include <string.h>  
    char* product(char *str, int k) {
      char *sf;
      int size = strlen(str);
      sf = malloc(((size*k)+1)*sizeof(char));
      for(int i=0; i<k; i++){
        for(int j=0; j<size; j++) {
          sf[(i*size)+j] = str[j];
      sf[size*k] = '\0';
      return sf;
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.