public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* help needed in fixing C programming error using cygwin !
@ 2001-12-12 18:05 Rahul
  2001-12-12 19:24 ` Jerrold Heyman
  2001-12-12 20:48 ` Eric M. Monsler
  0 siblings, 2 replies; 3+ messages in thread
From: Rahul @ 2001-12-12 18:05 UTC (permalink / raw)
  To: Cygwin@Cygwin. Com

Hi,

I am sorry for this little email, I failed to find any help anywhere else so
I am sending it to you guyz.

I am calculating LRC character and appending it at end of a string. It works
fine, except when the character is null.
i.e.. when (int)lrc = 0

This string is to be send to a modem port and I cannot figure out how to do
it. I am using cygwin and gcc compiler for this program.


Sample: Say "xmessage" is a big string of size 216 which already contain
some ASCII data.
I calculate LRC character,
then create a new string,
append STX to the new string,
followed by xmessage and
at end I append storelrc.
Problem : When LRC int value is 0 (zero) it do not get appended to message.
Part of program is below.
/* Now define LRC character */
auto char lrc='a';
auto char storelrc[2]="";
int I;
/* calculate lrc */
for(lrc=xmessage[0], I=1; xmessage[i]; I++) lrc^=xmessage[i];
/* and copy the LRC stored in lrc to storelrc variable */
(void) sprintf(storelrc,"");
(void) sprintf(storelrc,"%c", lrc);
/* create send message */
auto char revmesg[96];
(void) sprintf(revmesg, "");
(void) sprintf(revmesg, "%c" , STX);
(void) strcat(revmesg,xmessage);
/* will not work if (int)lrc is zero */
(void) strcat(revmesg,storelrc);
....
........


I appreciate any suggestions. Please accept my apology if you find it off
the topic.

Feedback
*********

Also there is a feedback on cygwin from my experience. It looks great works
good. But for newbies the installer lay out is very confusing. When we start
installer and it shows the screen from where one can choose what all
packages we want to download, source code etc .. the options are very
confusing and it seems lot of stuff is put on one single screen. It needs
few hit and trial to figure out  how to change options. Also the cygwin
desktop icon can be made a little more "sexier", Now that I am fan of
cygwin, I want its icon to look better than windows icons ... LOL ;-) For
Redhat it should not be a big deal to improve the graphics of a tiny icon.
Thanks for listening.

Regards,
Rahul




_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: help needed in fixing C programming error using cygwin !
  2001-12-12 18:05 help needed in fixing C programming error using cygwin ! Rahul
@ 2001-12-12 19:24 ` Jerrold Heyman
  2001-12-12 20:48 ` Eric M. Monsler
  1 sibling, 0 replies; 3+ messages in thread
From: Jerrold Heyman @ 2001-12-12 19:24 UTC (permalink / raw)
  To: Rahul; +Cc: Cygwin@Cygwin. Com

While not directly related to cygwin, the problem is as follows:

you are attempting to print an value of zero into the string -
unfortunately, ASCII 0 == NULL, which is a character string termination
character.

You wind up with possibly two NULL bytes at the end of your string.
You'll need to use something other than ASCII 0 to terminate your
message string - otherwise you'll never know you got the termination.

jerry

On Wed, 12 Dec 2001, Rahul wrote:

> Hi,
> 
> I am sorry for this little email, I failed to find any help anywhere else so
> I am sending it to you guyz.
> 
> I am calculating LRC character and appending it at end of a string. It works
> fine, except when the character is null.
> i.e.. when (int)lrc = 0
> 
> This string is to be send to a modem port and I cannot figure out how to do
> it. I am using cygwin and gcc compiler for this program.
> 
> 
> Sample: Say "xmessage" is a big string of size 216 which already contain
> some ASCII data.
> I calculate LRC character,
> then create a new string,
> append STX to the new string,
> followed by xmessage and
> at end I append storelrc.
> Problem : When LRC int value is 0 (zero) it do not get appended to message.
> Part of program is below.
> /* Now define LRC character */
> auto char lrc='a';
> auto char storelrc[2]="";
> int I;
> /* calculate lrc */
> for(lrc=xmessage[0], I=1; xmessage[i]; I++) lrc^=xmessage[i];
> /* and copy the LRC stored in lrc to storelrc variable */
> (void) sprintf(storelrc,"");
> (void) sprintf(storelrc,"%c", lrc);
> /* create send message */
> auto char revmesg[96];
> (void) sprintf(revmesg, "");
> (void) sprintf(revmesg, "%c" , STX);
> (void) strcat(revmesg,xmessage);
> /* will not work if (int)lrc is zero */
> (void) strcat(revmesg,storelrc);
> ....
> ........
> 
> 
> I appreciate any suggestions. Please accept my apology if you find it off
> the topic.
> 
> Feedback
> *********
> 
> Also there is a feedback on cygwin from my experience. It looks great works
> good. But for newbies the installer lay out is very confusing. When we start
> installer and it shows the screen from where one can choose what all
> packages we want to download, source code etc .. the options are very
> confusing and it seems lot of stuff is put on one single screen. It needs
> few hit and trial to figure out  how to change options. Also the cygwin
> desktop icon can be made a little more "sexier", Now that I am fan of
> cygwin, I want its icon to look better than windows icons ... LOL ;-) For
> Redhat it should not be a big deal to improve the graphics of a tiny icon.
> Thanks for listening.
> 
> Regards,
> Rahul
> 
> 
> 
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 

Jerry Heyman   919.224.1442    | IBM SWG/Tivoli Software |"Software is the 
Build Infrastructure Architect | 3901 S Miami Blvd       | difference between
jheyman@dev.tivoli.com         | RTP, NC  27709          | hardware and reality"
                     http://www.acm.org/~heymanj


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: help needed in fixing C programming error using cygwin !
  2001-12-12 18:05 help needed in fixing C programming error using cygwin ! Rahul
  2001-12-12 19:24 ` Jerrold Heyman
@ 2001-12-12 20:48 ` Eric M. Monsler
  1 sibling, 0 replies; 3+ messages in thread
From: Eric M. Monsler @ 2001-12-12 20:48 UTC (permalink / raw)
  To: rahul_cali_us; +Cc: Cygwin@Cygwin. Com


Don't use strings for binary data.

Use an explicit character array, keeping track of the length yourself. 
When you send it to a device, you'll have to use read/write rather than
string operations.

It does seem convenient to use string functions, but you'll never get
around the magic nature of null characters without more trouble than it
is worth.  I went through this doing messaging across a serial port.

Eric M. Monsler

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-12-13  3:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-12 18:05 help needed in fixing C programming error using cygwin ! Rahul
2001-12-12 19:24 ` Jerrold Heyman
2001-12-12 20:48 ` Eric M. Monsler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).