Operating System - OpenVMS
1829161 Members
11275 Online
109986 Solutions
New Discussion

SYS$QIO and C string termination

 
AntBark
Occasional Advisor

SYS$QIO and C string termination

Hi
I'm using SYS$QIO to retreive a string from a device - it works fine accept that the 3rd char of the 7 char string is a null(\0) which is the termination of a string in C, so I can't get the whole string. Is there a way I can overcome this?
4 REPLIES 4
Antoniov.
Honored Contributor

Re: SYS$QIO and C string termination

Hello,
I can't understand if 3.rd char is wrong null or if you can read because end string.
In seceond case use memcpy instead strcpy function (you need pass string lenght).
If 1.st case you could post more details.

H.T.H.
@Antoniov
Antonio Maria Vigliotti
Ian Miller.
Honored Contributor

Re: SYS$QIO and C string termination

The QIO will read the string irrespective of terminators unless you specify special options (for terminal driver). See I/O status block - will contain number of bytes received. If expected 7 bytes use memcpy to copy the data.
____________________
Purely Personal Opinion
Stanley F Quayle
Valued Contributor

Re: SYS$QIO and C string termination

The idea that \0 terminates a string is only used by C. The I/O Status Block (IOSB) returns the number of characters written to the string.

You're going to have to keep that size separately, and use functions that don't check for \0 (like memcpy instead of strcpy, as previously suggested).

Allowing nulls in strings is one reason that VMS uses string descriptors -- which is another thing that C doesn't do very well.
http://www.stanq.com/charon-vax.html
Stanley F Quayle
Valued Contributor

Re: SYS$QIO and C string termination

How about assigning some points to the responses?

Pointer to help on points:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33

Thanks in advance.
http://www.stanq.com/charon-vax.html