Guest User

Untitled

a guest
Jan 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. int a,b,i,j;
  2. char **t;
  3. printf("Nombre de lignes ?");
  4. scanf("%d", &a);
  5. printf("Nombre de colonnes ?");
  6. scanf("%d", &b);
  7.  
  8. t = malloc(a*sizeof(char*)); // Allocation de mémoire pour la variable t
  9. for(i=0; i < a ; i++)
  10. {
  11. t[i] = malloc(b*sizeof(char));
  12. }
  13.  
  14. for (i=0 ; i<a ; i++)
  15. {
  16. for (j=0 ; j<b ; j++)
  17. {
  18. t[i][j]='*';
  19. t[i][j+1]='\0';
  20. }
  21. }
  22.  
  23. for (i=0 ; i<a ; i=i+1)
  24. {
  25. printf("%s\n",t[i]);
  26. }
  27.  
  28. for(i = 0; i < a; i++)
  29. {
  30. free(t[i]);
  31. }
  32. free(t);
Add Comment
Please, Sign In to add comment