error using malloc

I have the following code:

#include <avr/pgmspace.h>

String message = "AB";

const int messageLength = message.length() * 8;

int *ptr_one = (int *)malloc(sizeof(int));

*ptr_one = messageLength;

const int arrayCombined[8][8] PROGMEM = {};

and I get this error:

error: expected constructor, destructor, or type conversion before '=' token

*ptr_one = messageLength;

^

Anyone know what the cause of this is?

What happens if you use ptr_one as an array, as it was intended to be used?

   ptr_one[0] = messageLength;

Doing it this way makes it obvious that ptr_one is a dumb name.

ASSuming that malloc() allocated data is NOT a good idea.

Posting snippets is NOT a good idea, either.

Is your assignment statement "*ptr_one = messageLength;" inside a function or just hanging out there in "Global Land"? As mentioned, only posting a snippet makes it impossible to know.

Everything in my snippet is just hanging out in "Global Land". Why is it intended to be used as an array?

Try putting "*ptr_one = messageLength;" inside a function like setup(), loop(), myFunction(), etc.

Why is it intended to be used as an array?

Why else would you allocate a block of memory?

PaulS:
Why else would you allocate a block of memory?

Linked List, Binary Tree.

gfvalvo:
Linked List, Binary Tree.

I wanted OP to answer that question. It doesn't make sense to me to allocate an array of ints that is as longs as some the string some String instance wrapped, and then store the length of the string in the first position.