what does this statement mean? from virtualwire library

Ok this is code for a transmitter to send but I do not understand it at all

const char *msg = "hello";
vw_send((uint8_t *)msg, strlen(msg));

I know the vw_send takes two parameters which are vw_send(message, length) but the above code makes no sense? What is the * for? And why is msg defined as a pointer? Why is it cons char and not just char?

but the above code makes no sense?

It makes perfect sense.
A constant string is defined (const char*), but "vw_send" expects a "uint_8" array, so cast the pointer to the string to be a pointer to "uint8_t".

Just slow down abit please, I don't even understand pointers. And believe me I have been reading my balls off and I just don't get it.

Also what is the difference between a normal array and a uint8_t array?

Char normal_array[] = "programming is difficult"

Now what is a uint8_t array? What does that even mean?

Also what is the difference between a normal array and a uint8_t array?

I can't think of what a "normal" array might be.

char normal_array[] = "ABCDEF"

Tells the compiler to reserve seven bytes of RAM, and before the program runs, populate that memory with the six characters 'A', 'B', 'C', 'D', 'E', 'F' and zero.

uint8_t normal_array[] = "ABCDEF"

Tells the compiler to reserve seven bytes of RAM, and before the program runs, populate that memory with the six characters 'A', 'B', 'C', 'D', 'E', 'F' and zero.

So, no diference?
Well, yes, because "char" and "uint8_t" are not exactly the same thing - they occupy the same amount of memory (one byte) but the compiler treats arithmetic on the two types differently.

BUT vw_send isn't going to do any arithmetic, so it is perfectly OK to tell the compiler to treat the pointer you give to vw_send as a pointer to a "different" type.

A pointer is simply a memory address.

Ok I get about a tenth of what ur saying. Not cause it doesn't make sense, it makes sense but just not to me because I am new to all this.

So is uint8_t a data type? Like char, int, float, long int, double etc?

What do u mean the compiler treats arithmetic differently between the two?

Another question.

If I create a variable and a pointer like this

Int variable = 5;
Int *pointer = &variable

Why does the code in the virtual wire not make the pointer to point to an address of a variable?

And why is the * after uint8_t and not before it? Example

*uint8_t
uint8_t *

Why is the star after that?

Yes, it's just a data type.

A uint8_t is a an unsigned eight bit value.
A char is also called int8_t, so is a signed eight bit value.

Signed and unsigned datatypes have slightly different arithmetical properties.

vw_send((uint8_t *)msg, strlen(msg));

Look at that line. What is the * for after uint8_t

AWOL:
Yes, it's just a data type.

A uint8_t is a an unsigned eight bit value.
A char is also called int8_t, so is a signed eight bit value.

Signed and unsigned datatypes have slightly different arithmetical properties.

Thank you, what do u mean when u say arithmetic properties?

Why does the code in the virtual wire not make the pointer to point to an address of a variable?

A variable or constant, it doesn't really matter.

By constant do u mean "this is a constant"?

what do u mean when u say arithmetic properties?

I mean a signed char holds values from -128 to +127, whereas an unsigned char holds values from 0 into 255.
Same number of different values, but different properties.

Why do you keep abbreviating the word "you"?

It's a habit from texting I am sorry. I do not think you understand how stupid I am. Your explanations are far to complex for me to grasp. It feels as if I will never pass this barrier in programming. I will never learn anything more because the way people explain stuff does not make sense to me. And believe me I have googled my face off for many months

calvingloster:
vw_send((uint8_t *)msg, strlen(msg));

Look at that line. What is the * for after uint8_t

Another reason why I will probably never pass this barrier is because people do not answer questions I have. It happens all the time. Like the above question. It is just ignored and I stay confused

What is the * for after uint8_t

I thought you said you'd read about pointers?

If the asterisk isn't there, it's just a simple variable. With the asterisk, it's a pointer (variable).

A pointer is a really simple concept.

If I send you a letter (the things people had to write to other people before email was invented), I put your address on the letter.

I don't put your house on the letter - that would make the postman's job way too difficult.

I write a pointer to your house on the letter.

If I increment the address on the letter, the letter goes to the house across the road.

AWOL:
A pointer is a really simple concept.

If I send you a letter (the things people had to write to other people before email was invented), I put your address on the letter.

I don't put your house on the letter - that would make the postman's job way too difficult.

I write a pointer to your house on the letter.

If I increment the address on the letter, the letter goes to the house across the road.

ROFL!!! Sorry! Glad I wasn't drinking something when I read this.

I know how this person feels. I remember when I was introduced to pointers. They were in my mind, useless confusing nonsense.

Hang in there calvingloster, you'll get it. Suddenly you'll get the "Oh! That's all it was?!" And you'll be on your way. Keep asking if you don't get it, we'll try other "illustrations" 'till we hit on the one that works.

-jim lee

AWOL:

What is the * for after uint8_t

I thought you said you'd read about pointers?

If the asterisk isn't there, it's just a simple variable. With the asterisk, it's a pointer (variable).

You are not answering my question. Why is the asterisk BEHIND and not infront of the variable?

vw_send((uint8_t *)msg, strlen(msg));

The way u declare a pointer is;

Int *pointer

Not like this

Int pointer *

The way u declare a pointer is;

But you're not declaring a pointer, you're telling the compiler that you want it to treat one type of pointer as another type of pointer.

The star goes after the variable type name.

In the example you show above...

vw_send((uint8_t *)msg, strlen(msg));

The * is in front of the variable. msg is the variable, uint8_t is the type of variable.

When you say..

unsigned int varName;

You are telling the compiler to treat varName as an unsigned integer.

(char*) varName

You are telling the compiler to treat varName as a pointer to a character. (As the address of a memory location that is holding a character.)

(int) varName

You are telling the compiler to now treat varName as an int.

Now, is it char* X; or char X; ? They both work. I see mostly the char X; version.

Hope this helps.

-jim lee