Guest User

Untitled

a guest
Jan 20th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. // by xgeek
  6. void main() {
  7.   char *chaine;
  8.   char format[50];
  9.   int taille;
  10.   printf("Taille: ");scanf("%d",&taille);
  11.   chaine = calloc(taille + 1,sizeof(char)); // allocation dynamique
  12.   sprintf(format,"%%%ds",taille);
  13.   scanf(format,chaine);
  14.   printf("%s\n",chaine);
  15.   free(chaine);
  16.  
  17. }
Add Comment
Please, Sign In to add comment