Note that there are some explanatory texts on larger screens.

plurals
  1. POConversion of a char array to an int pointer
    primarykey
    data
    text
    <p>I have a string object called <code>Message</code> that is given a string such as:</p> <pre><code>Message = "Hello"; </code></pre> <p>Each character is then stored in a character array:</p> <pre><code>void Load() { Message.toUpperCase(); // Makes all the characters uppercase for (int T = 0; T &lt; Message.length(); T++) { Storage[T] = Message.charAt(T); } } </code></pre> <p>This part works fine.</p> <p>Now I want to call a function that needs to be passed a integer pointer pointing to an array that maps out the bit values needed to display a character on a 5*7 LED matrix.</p> <p>Normally I would be able to call <code>Display(H)</code> (<code>void Display(int Array[])</code>), and it would be fine. However, I want to use the string array so that it can be done automatically. The problem is that when using H normally it is seen as an integer pointer and it works great. Storage holds char's that are not pointers, and this creates problems.</p> <p>I have tried various ways of converting it, but all seem to fail. Is this even possible?</p> <p>This is what I have tried:</p> <pre><code>char to int: int w = int(Storage[L]); int* ww = &amp;w; </code></pre> <p>This compiles fine, but the output is all wrong. So I am not really sure how to take this further.</p> <p>Just to clarify, this works:</p> <pre><code>int A[] = {0x1B, 0x15, 0xE, 0xE, 0x0, 0xE, 0xE, 0xE}; Display(A); </code></pre> <p>But this does not:</p> <pre><code>String[L] = A; int w = int(Storage[L]); int* ww = &amp;w; Display(ww); </code></pre> <p>I'm probably doing something silly, but I can't see it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload