I tried to write a pice of code that lets the user enter an infinite (limited only by memory) amount of strings where each string can be up to 298 chars long (array of 298 with one '\n' and '\0' in the end). The end signal should be EOF (Strg+Z on Win, Stg+D on Linux). The code down there works just fine when i change EOF to 'a' or any other char but not with EOF. I would love to debugg it, but unfortunately i cannot put an EOF into my terminal in eclipse. So does anyone know why there's a difference between EOF (which should be -1) and a char or how to put in an EOF in eclipse?
while(boolean == 0)
{
fgets(buff_memory, 300, stdin);
for (i = 0; i < 300; i++)
{
if (buff_memory[i] == EOF)
{
all_memory[current_max - 1] = '\0';
boolean = 1;
break;
}
else if (buff_memory[i] == '\0')
{
break;
}
else
{
all_memory[current_max - 1] = buff_memory[i];
buff_memory[i] = '\0';
current_max++;
all_memory = (char *)realloc(all_memory, current_max * sizeof(*all_memory));
}
}