Basically the title is self explaining. I'm programming in C and i use fgets as the input function but i do not want that control character开发者_开发知识库s get printed.
fgets()
is rather simple, and doesn't offer you much control over what appears on the screen. I don't think that it's possible to do this. You may want to look into something more powerful - like readline.
Yes, as other post says, readline
is your best bet. Its simple too. If you are on Linux, it should already be installed. try the following:
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
// compile as: gcc <file>.c -lreadline -lcurses
int main (int argc, char *argv[])
{
char *input = readline("Enter words: ");
printf("\n Input: [%s]\n", input );
return 0;
}
-- HTH.
精彩评论