Skip to content

Instantly share code, notes, and snippets.

@BalintCsala
Created November 9, 2019 18:20
Show Gist options
  • Save BalintCsala/ca5447097f293ba97b1055baa7c4837c to your computer and use it in GitHub Desktop.
Save BalintCsala/ca5447097f293ba97b1055baa7c4837c to your computer and use it in GitHub Desktop.
void ismeretlen_hossz_olvas(FILE *input, char **str)
{
size_t hossz = 1;
*str = malloc(1 + 1); // karakter + null terminátor
char c;
int i;
for (i = 0; fscanf(input, "%c", &c) != EOF && c != '\n'; i++) {
if (i >= hossz) {
hossz *= 2;
*str = realloc(*str, hossz + 1);
}
(*str)[i] = c;
}
(*str)[i] = '\0';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment