I always get this error message!
Here's the code:
What did I do wrong?
Thanks!
Here's the code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *string;
char length_string = 0;
char buffer_for_string = 0;
char *temp_one = malloc(sizeof(char));
if(temp_one == NULL)
{
free(string);
return -2;
}
else
{
string = temp_one;
temp_one = NULL;
}
while((buffer_for_string = getchar()) != EOF)
{
**string = buffer_for_string; // error appears here
char *temp_two = realloc(*string, sizeof(char)*(length_string+1));
if(temp_two == NULL)
{
free(string);
return -2;
}
else
{
string = temp_two;
temp_two = NULL;
}
length_string++;
}
getchar();
return 0;
}
Thanks!
Comment