Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char* input_string()
- {
- // getchar(); //on vide le buffer, cette ligne est optionnelle
- int n = 0;
- char *c = (char*) malloc(1);
- char saisie = getchar();
- while(saisie != '\n')
- {
- c[n] = saisie;
- saisie = getchar();
- n++;
- c = (char*) realloc(c, n+1);
- }
- c[n] = '\0';
- return c;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement