From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 11 23:22:30 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 94FD516A4CE for ; Fri, 11 Mar 2005 23:22:30 +0000 (GMT) Received: from mail.revolutionsp.com (ganymede.revolutionsp.com [64.246.0.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 36A9743D54 for ; Fri, 11 Mar 2005 23:22:30 +0000 (GMT) (envelope-from security@revolutionsp.com) Received: from mail.revolutionsp.com (localhost [127.0.0.1]) by mail.revolutionsp.com (Postfix) with ESMTP id 35F7915C9E for ; Fri, 11 Mar 2005 17:21:55 -0600 (CST) Received: from 81.84.174.5 (SquirrelMail authenticated user security@revolutionsp.com) by mail.revolutionsp.com with HTTP; Fri, 11 Mar 2005 17:21:55 -0600 (CST) Message-ID: <62680.81.84.174.5.1110583315.squirrel@mail.revolutionsp.com> In-Reply-To: References: <61969.81.84.174.5.1110478195.squirrel@mail.revolutionsp.com> Date: Fri, 11 Mar 2005 17:21:55 -0600 (CST) From: "H. S." To: freebsd-hackers@freebsd.org User-Agent: SquirrelMail/1.4.4 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: basic programming questions X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Mar 2005 23:22:30 -0000 Hey, thanks a lot man, really appreciated :-) Meanwhile the program has it's base already working, very nice since I didn't touch C for quite some time now (I used to program when I was younger, then shifted to system administration and shell scripting), but I'm enjoying getting things done on my own :) By the way, you know a link for a good and complete C manual for free ? Oh, and BTW. I've ran across a problem. I think I knew how to fix this, but it's beating me right now. Near the end of main() I printf'd some text and am expecting a y/n response from user. I scanf("%c", &userfeed); right after, but it printf's and ignores the scanf. I might know what's going on, some characters on the buffer are not "cleared", and so scanf is beind fed one of these characters. My memory says that fflush() should fix this, but it's not working. I've also tried getchar() but it didn't work either (or I did it in a wrong way).. I'm missing something obvious here! What should I do to correct this? And is my buffer-not-empty-so-scanf-gets-a-waiting-character theory correct ? Your curses program and the links the other people gave were great, thanks to all :) > On Thu, 10 Mar 2005, H. S. wrote: > >>Hey, >> >>Sorry if this is a little offtopic, but I need some basic help with C. >> >>I'm not a programmer, but I need to get something done in C for a >> project. >>I need to do a console application, and as I've got some free time, I'd >>like to add bold sentences and characters with other colors (ie blue, >> red, >>etc), to make it prettier. >> >>As my C skills go as far as declaring variables, making loops, and >> knowing >>my way around pointers, I really do not know where to start looking for >>the header file including these functions! I also need a function to >> clear >>the screen (in order to re-draw it). >> >>Could anyone point me to the right header files, and perhaps suggest some >>programs that use these functions so I can have something to start with? > > > Here's a little program I just wrote for you: > > > #include > > main() > { > initscr(); > start_color(); > > /* we want blue text on a white background */ > init_pair(1, COLOR_BLUE, COLOR_WHITE); > color_set(1, NULL); > > clear(); > > mvprintw(10,20, "Hello, world"); > refresh(); > > endwin(); > } > > > I compiled with: > > cc -o test test.c -lncurses > > and it demonstrates what you want :- clearing the screen and writing text > in color at a specific location (10 down, 20 across.) > > If you don't need to position the text, you can use plain "printw" without > the x,y. printw is like printf. > > Hope this helps, > > Aled >