LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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: slackware 14.2 kernel 4.19.43
Posts: 462

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
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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: slackware 14.2 kernel 4.19.43
Posts: 462

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: slackware 14.2 kernel 4.19.43
Posts: 462

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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:41 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration