LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-25-2005, 03:15 PM   #1
slzckboy
Member
 
Registered: May 2005
Location: uk - Reading
Distribution: slack 10.2 kde 3.4.2 kernel 2.6.15
Posts: 452

Rep: Reputation: 30
ncurses printing character array prob.


Code:
        .....

        if(FD_ISSET(sockfd,&myset)){
	if((bytes_in=recv(sockfd,recvBuff,RECVBUFF,0)) < 0)
	irc_error("myirc:recv()");

	if(pong(recvBuff,sockfd))
	continue;

	if(bytes_in){
	recvBuff[bytes_in]='\0';
	if((printw("%s",recvBuff))==ERR)
	irc_error("myirc:ircConnect:printw");
	printw("seems ok.\n");
	refresh();
	}
Hi all..
Code above uses the select() call to receive a string messages from an irc server on a socket file descriptor and print it out to standard output.

you see the line if((printw("%s",recvBuff))==ERR)...

well when i run this program using stdio.h functions ,i.e using printf() it works fine and I get
the message recieved by my call to recv() sent to the screen.

But when I use the printw on the character array recvBuff I just get blank space where my text should be.???

Wot am i doing wrong?
the "printw("seems ok.\n");" call works fine!!?!

thnk you.
 
Old 07-25-2005, 05:02 PM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,300

Rep: Reputation: 69
Maybe you should use wprintw() instead ?

Last edited by keefaz; 07-25-2005 at 05:05 PM.
 
Old 07-25-2005, 05:16 PM   #3
slzckboy
Member
 
Registered: May 2005
Location: uk - Reading
Distribution: slack 10.2 kde 3.4.2 kernel 2.6.15
Posts: 452

Original Poster
Rep: Reputation: 30
just this minute tried wprintw(stdscr,"%s",recvBuff);

same thing...

where there should be text there is just a block of blank lines ?
 
Old 07-31-2005, 08:51 AM   #4
slzckboy
Member
 
Registered: May 2005
Location: uk - Reading
Distribution: slack 10.2 kde 3.4.2 kernel 2.6.15
Posts: 452

Original Poster
Rep: Reputation: 30
fyi

its because all messages recived from an irc server have the suffix "\r\n"

the carriage retrun causes the cursor position to be set to the first column of the current line.
Then the first thing that waddch or addch(they are used for wprintw or printw respectively) does when seeing the newline character is do a clrtoeol() which clears everything from the right of the cursor.
It will then print a newline.
tyhanks for Thomas Dickey http://dickey.his.com/ for pointing this out to me.

always read the man page eh?!!!!


ahh... on to the next issue.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ncurses wide character/extended ASCII problem Hosiah Programming 3 03-03-2009 12:55 PM
SIGSEGV: Array of character pointers?? usercsr Programming 2 04-23-2005 11:34 AM
function won ' t return character array word Linh Programming 1 07-31-2003 06:11 PM
C can 't return a character array Linh Programming 5 06-18-2003 04:58 AM
Cannot pass and return a character array Linh Programming 1 06-12-2003 04:17 PM


All times are GMT -5. The time now is 08:55 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration