opps... i noticed that the code i posted first was a bit wrong ...
Code:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINES 25
main()
{
clrscr();
char name[15];
char subject[15];
char msg[100];
textcolor(7);gotoxy(3,5);
cprintf("Name:");
gets(name);
textcolor(7);gotoxy(3,7);
cprintf("Subject:");
gets(subject);
int get_lines(char *lines[]);
char *lines[MAXLINES];
int number_of_lines;
/* Read in the lines from the keyboard. */
number_of_lines = get_lines(lines);
if ( number_of_lines < 0 )
{
puts(" Memory allocation error");
exit(-1);
}
return(0);
}
int get_lines(char *lines[])
{
int n = 0;
char buffer[80]; /* Temporary storage for each line. */
gotoxy(3,9);cprintf("Message:");
while ((n < MAXLINES) && (gets(buffer) != 0) &&
(buffer[0] != '\0'))
{
if ((lines[n] = (char *)malloc(strlen(buffer)+1)) == NULL)
return -1;
strcpy( lines[n++], buffer );
}
return n;
}
this part was not intented for the code
Code:
textcolor(7);gotoxy(3,9);
cprintf("Message:");
gets(msg);
Are you trying to input all the message lines using one gets()? If so, think about doing one line at a time and I'll bet the light will come on....
hm... one line at a time ?? seems like a way out..
let me see if i get this clear....
i use one gets() per line, but when the user double enters the message is done !!
hm.... seem easy !! but m i on the right track ??
thanks for the explaination WaltP....
i'll work on it and display what i come out with in a bit...