FiddleComputers

input_string

Oct 27th, 2020
909
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. char* input_string()
  2. {
  3.     // getchar(); //on vide le buffer, cette ligne est optionnelle
  4.  
  5.     int n = 0;
  6.     char *c = (char*) malloc(1);
  7.     char saisie = getchar();
  8.     while(saisie != '\n')
  9.     {
  10.         c[n] = saisie;
  11.         saisie = getchar();
  12.         n++;
  13.         c = (char*) realloc(c, n+1);
  14.     }
  15.  
  16.     c[n] = '\0';
  17.  
  18.     return c;
  19. }
  20.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×