What's the difference between an object and a char

Good day,

I am discovering that way to store value

struct MyUrl {
	char id[IMEISIZE];
	char hour[9];
	char valid[7];
	char lat[6];
	char latn[2];
	char lon[5];
	char lone[2];
	char speed[8];
	char heading[10];
	char batt[7];
	char desc[7];
	char gpsloc[20];
	char gsmloc[24];
	char time[12];
};

MyUrl url = {
            "?id=",
            "&hdop",
            "&lat=",
            //"&latn=",
            "&lon=",
            //"&lone=",
            "&speed=",
            "&heading=",
            "&batt=",
            "&desc=",
            "GPS%20Location:%20",
            "Cell%20Tower%20Location",
            "&timestamp=20",
          };

I also can create a char like this

char fix[10];

or

char fix[200];

If I use 200 it take more sace in my memory than 10.

What I do not undersdand.

In object

struct MyUrl {
	char id[IMEISIZE];
	char hour[9];
	char valid[7];
	char lat[6];
	char latn[2];
	char lon[5];
	char lone[2];
	char speed[8];
	char heading[10];
	char batt[7];
	char desc[7];
	char gpsloc[20];
	char gsmloc[24];
	char time[12];
};

I started with the id key, then I added the hour, then the valid and et lat, ect.

Each time , I compiled and I have not see decreasing the size of free speace.
Why? Does it nor take space?

What append, If I change
char time[12] to char time[200]?

How does work exactely a structure? What do I have to take care for?

Thankd for you clarification
Cheers

If you don't use the structure, it won't take up any space at all.
Do you use the structure?

You don't have any chars in the code you posted you have ARRAYS of char.

What's the difference between an object and a char

The question makes no sense.

Mark

I wonder are you defining the struct but not actually creating an instance of it?

I think it would be something like MyUrl myVar; to create a variable that uses the struct.

...R

I am sorry but I do not know what's a structure :frowning: . I am really a beginer with this topics
I could make working this:

struct MyFix {
   char position[FIXSIZE];
 };

char test[] = "tototo"

MyFix fix;
memcpy(fix.position,test);

Serial.print(fix.position);

Then now I am trying to do something bigger as the MyUrl code, I pasted

@holmes
Yes I did it (scroll)

struct MyUrl {
 char id[IMEISIZE];
 char hour[9];
 char valid[7];
 char lat[6];
 char latn[2];
 char lon[5];
 char lone[2];
 char speed[8];
 char heading[10];
 char batt[7];
 char desc[7];
 char gpsloc[20];
 char gsmloc[24];
 char time[12];
};

MyUrl url = {
            "?id=",
            "&hdop",
            "&lat=",
            //"&latn=",
            "&lon=",
            //"&lone=",
            "&speed=",
            "&heading=",
            "&batt=",
            "&desc=",
            "GPS%20Location:%20",
            "Cell%20Tower%20Location",
            "&timestamp=20",
          };

Later, I can do it

Serial.println(ur.id); // print : ?id=
Serial.println(ur.lat); // print &lat=
Serial.println(ur.lon); // print &lon=

etc.

But I can not understand the size of the memory, the MyUrl url takes.

Do you understand my worries?

I am sorry but I do not know what's a structure

struct MyUrl {

Huh?

Please can you post a whole program rather than just snippets.

Huh, what? :slight_smile:
What do you means?

I know that is a structure, but I have no more knoledge to copy past an exemple.

What’s the benefict of

using this

struct MyUrl {
 char id[IMEISIZE];
 char hour[9];
 char valid[7];
 char lat[6];
 char latn[2];
 char lon[5];
 char lone[2];
 char speed[8];
 char heading[10];
 char batt[7];
 char desc[7];
 char gpsloc[20];
 char gsmloc[24];
 char time[12];
};

or

char id[IMEISIZE];
 char hour[9];
 char valid[7];
 char lat[6];
 char latn[2];
 char lon[5];
 char lone[2];
 char speed[8];
 char heading[10];
 char batt[7];
 char desc[7];
 char gpsloc[20];
 char gsmloc[24];
 char time[12];

I discovered, but I am not sure to be correct, that the struct do not affect that message. If I incease the size of spped to 100, it will not change. But I am basolutely not sure, about what I am stating…

Sketch uses 29,300 bytes (95%) of program storage space.

"Huh?" means "you say you don't know what a structure is, yet you use one in your sketch, and started a thread about it. Why is that?"

HTH

Variable structs don't go in flash memory

pierrot10:
Do you understand my worries?

NO.

You seem to have a program that does what you want. Why should you have worries?

...R