#include
#include
#include
char *mygetline(char *line, int size)
{
char *com_line;
int len;
com_line = (char *)malloc (size);
while ( fgets(line, size, stdin) != NULL ){
len = strlen(line);
if( line[len-1] == '\n' )
line[len-1] = 0;
strcat(com_line,line);
}
return com_line;
}
int main(void)
{
char text[101] = "";
fputs("prompt: ", stdout);
fflush(stdout);
printf("text = \"%s\"\n", mygetline(text, sizeof text) );
return 0;
}
/*
http://cboard.cprogramming.com/c-programming/70320-how-remove-newline-string.html
*/
2010年7月11日 星期日
訂閱:
張貼留言 (Atom)
0 意見:
張貼留言