LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Display string with ascii 0

Hi everybody,
anyone knows how is possible display a string with inside some byte at 0
(zero) ???
For example i'd like to show this string:

"Hello word" , but value of space is 0.

If i use string object or text box or canvas, result will be only "Hello"

Any suggest ???


0 Kudos
Message 1 of 3
(3,385 Views)

Marco,

 

This is some very basic C ! In C strings are made as an array of char. A string is by definition terminated with the '\0' character which has the value 0. Anything after the '\0' is not considered to be part of the string, even if that is in the allocated memory space for the array of char. The function strlen() simply counts the number of chars from position 0 until it finds the '\0' character. (In contradiction to Pascal where the length of the string is stored in the first byte of the array of characters and no 'end-of-string character' is used).

Soultion:

I suppose you receive/have an array of chars. If you know for sure how many characters are in that array you can make a loop like:

for (i=0;i<lenght; i++){ if (arr[i] == 0) arr[i]=32; }

to clear the '\0' characters.

But make sure not the string is still terminated with a '\0' or you might experience some very strange effects in your program !

 

 

0 Kudos
Message 2 of 3
(3,382 Views)
Hi Marco!

   How do you assign the string to the panel control/indicator? And how is defined the variable containing the string? You can get different behaviour if you define a char[]="Hello world", instead of character by character.

   If I use SetCtrlVal(panel, PANEL_STRING, "Hello world");  I get the complete "Hello worls" string plotted!

   Please, let me know!

graziano
0 Kudos
Message 3 of 3
(3,369 Views)