Please dont double post.
Also, use code tags
Code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int getline(char line[],int max);
int main(void)
{
int nch = 0;
int c;
max = max - 1;
while((c = getchar*()) !=EOF)
{
if(c=='\n')
break;
if(nch<max)
{
line[nch] = c;
nch = nch + 1;
}
}
if(c==EOF&& nch ==0)
return EOF;
line[nch] = '\0';
return nch;
}
main()
{
char *temp_line_ptr;
char *line_ptr;
char **poem_ptr;
char **temp_poem_ptr;
printf("Enter a line of a poem\n",nch);
char *temp_line_ptr = nch;
len = malloc(strlen(*temp_line_ptr)+1);
strcpy(line_ptr,temp_line_ptr);
line_ptr = malloc(sizeof(CHAR)*len);
if(line_ptr == NULL)
{
printf("out of memory\n");
return
}
poem_ptr = malloc(sizeof(char*))
*poem_ptr = line_ptr;
while(getline(line,CHAR) != EOF)
{
*line_ptr = &temp_line_ptr;
**temp_poem_ptr = &poem_ptr;
}
temp_poem_ptr = realloc(poem_ptr,sizeof(char*));
if(temp_poem_ptr !=NULL)
{
line_ptr = temp_poem _ptr;
}
else
{
printf("out of memory\n");
}
*poem_ptr = line_ptr;
printf("\n,line_ptr)
free(line_ptr)
line_ptr = NULL;
}
Your code looks pretty messed up.
You declare getline(..) at the start of the program but you never actually make the method.
You however have two main methods.
You should really try doing this in small steps.