Zymeth

Untitled

May 22nd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void foo(char **t, int elemszam, int n)
  6. {
  7.    int max,i,akt_hossz;
  8.  
  9.    max=strlen(t[0]);
  10.  
  11.    for(i=1;i<elemszam;i++)
  12.          if(strlen(t[i])>max) max=strlen(t[i]);
  13.  
  14.    if(max>n) return ;
  15.  
  16.    char **vissza=(char**)calloc(elemszam,sizeof(char*));
  17.  
  18.    for(i=0;i<elemszam;i++)
  19.    {
  20.       vissza[i]=(char*)calloc(n,sizeof(char*));
  21.    }
  22.  
  23.    int index=0,kul,k;
  24.  
  25.    for(i=0;i<elemszam;i++)
  26.    {
  27.       kul =n-strlen(t[i]);
  28.  
  29.          for(k=0;k<kul;k++)
  30.             strcat(vissza[index],".");
  31.  
  32.          strcat(vissza[index],t[i]);
  33.          index++;
  34.    }
  35.  
  36.    for(i=0;i<elemszam;i++)
  37.    {
  38.       t[i]=vissza[i];
  39.    }
  40.  
  41.  
  42.  
  43. }
Add Comment
Please, Sign In to add comment