Jump to content

integer to char conversion


Recommended Posts

I have integer number in the range 0..255. I want to convert it to char with respective code. For example, I can write in the C language

printf("Char: %c\n",ch).

In LabView (block diagram) I found block "Format Into String" which is similar to printf() function. But it does not have support of %c specifier.

So, how I can perform described conversion?

Thank you.

Link to comment

QUOTE (alexadmin @ Mar 17 2008, 03:18 PM)

I have integer number in the range 0..255. I want to convert it to char with respective code. For example, I can write in the C language

printf("Char: %c\n",ch).

In LabView (block diagram) I found block "Format Into String" which is similar to printf() function. But it does not have support of %c specifier.

So, how I can perform described conversion?

Thank you.

Under numeric and datamanipulation you have type cast. Another option is byte array to string under the string palette in combination build array.

Link to comment

Here's what Anders said, in code:

post-2992-1205765974.png?width=400

Note that the U8s on the front panel are the same as any other U8. I added "(as hex)" just to make it clear that they're set to display in hex. The display format doesn't change the behavior of the U8 on the block diagram.

You can also use the same typecast operation with U16s, U32s, etc. and they'll be cast into multiple characters instead of just a single character as shown.

EDIT: Attached the file, 'cuz well, why not?

Download File:post-2992-1205766284.vi

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.