int main(int argc, char* argv[])
{
char* speicher = NULL;
char* tmp = NULL;
size_t size = 0;
char c = 0;
while((c = fgetc(stdin)) != EOF)
{
size++;
tmp = (char*)malloc(size);
if(tmp == NULL)
{
printf("Error: Out of memory!\n");
return 1;
}
memcpy(tmp,speicher,size);
speicher = (char*)realloc(speicher,size);
if(speicher == NULL)
{
printf("Error: Out of memory!\n");
return 1;
}
memcpy(speicher,tmp,size);
speicher[size] = c;
free(tmp);
}
//Nun zur Ausgabe
for(size_t i = size;i>0;i--)
{
printf("%c",speicher[i]);
}
printf("\n");
free(speicher);
return 0;
}