string format- replacing a string with a string format

This method gets a pointer called headrD , and :

char getheader[200];
 sprintf(getheader,"GET /%s HTTP/1.1\r\n",headrD); 
          
          char *hdr[] =
          { 
             
            getheader,
            "Host:xx.xx.xx.xx\r\n", 
            "User-Agent:runscope/0.1\r\n",
            "Content-Type:application/json\r\n",
            "Connection:close\r\n\r\n\r\n", 
             NULL
          };

I would like to eliminate the use of the char array getheader[200] , and put into the hdr[] array - the whole structure directly, skipping the sprintf ,

How would i do that ?

thank you .

Leave it in flash memory, where it belongs.

(That was just a snippet of my full answer)

I would like to eliminate the use of the char array getheader[200] , and put into the hdr[] array - the whole structure directly, skipping the sprintf ,

Put WHAT into the hdr array? That array is defined to contain a pointer to the space reserved by the getheader variable.

You must still reserve that space (although 200 bytes seems excessive). You must still populate it somehow.

Most of that data, that you are forcing to be copied to SRAM does not need to be, as Groove alludes to.

"Most of that data, that you are forcing to be copied to SRAM does not need to be"

What does it means ? how do i force to copy to SRAM ? i am not sure i get you ,or the snippets of the other respond .

I was thinking that the fact that i declare the 200 indexes array is a wast of memory and wanted a syntax to something like :

   char *hdr[] =
          { 
             
            ("GET /%s HTTP/1.1\r\n",headrD),
            "Host:xx.xx.xx.xx\r\n", 
            "User-Agent:runscope/0.1\r\n",
            "Content-Type:application/json\r\n",
            "Connection:close\r\n\r\n\r\n", 
             NULL
          };

Wish about syntax all you like, it isn't going to change the rules.

If all of the picture of your problem you give us is taken through a keyhole, all you're going to get is even smaller images of the complete answer.

This method

You mispelled "uncompilable scrap".

Seriously, wise-up and start helping people to help you.

Wow. People here are really takes this too seriously, like there are some rules and we all have to follow the nerds rules as you see them.

Why is it seems like you angry all the time ?

2 options, you want to be here (you are not always angry for every detail) you not want to be here- so dont help me at all (!)

This is the way i am thinking and i know you have here these obsession to see other people's code and know what they do ,

but honestly, i cant show you this code, because you would know things i dont want you to know .

(oh no, now your ego was exploded, where you understand i am not bond to your rules )

oh no, now your ego was exploded, where you understand i am not bond to your rules

Not at all. But, I've decided that when the poster is you, I'm just going to give the thread a pass.

Has there.been a stupid epidemic, and I missed it on the news?

If you want to fail your school assignment, just carry on as you are.
If you want help, start joining in.

It's really very, very simple.

BTW, the syntax of C is not negotiable, or a "nerd rule"

This is the way i am thinking

I think the jury is still out on that question

BenStlr:

"Most of that data, that you are forcing to be copied to SRAM does not need to be"

What does it means ? how do i force to copy to SRAM ? i am not sure i get you ,or the snippets of the other respond .

You forced it into RAM when you defined your char pointer array and initialised it with a string.

You are in this so far over your head, you don't even realise.
It's like you're trying to build a petrol engine, when all you're ever seen are twigs.

Come back when you've read some basic programming texts.

2 options, you want to be here (you are not always angry for every detail) you not want to be here- so dont help me at all (!)

You forgot the option where we help you to get help, because Man! (or Woman!), you really need help