Insert char array to char array in c -


i insert char array in char array

char test[100]="www.bing.com ";  char headers[256] = "get /index http/1.1\r\nhost: www.bing.com\r\nuser-agent: mozilla/5.0 (compatible; msie 8.0; windows nt 6.0)\r\nreferer: \r\nconnection: close\r\n\r\n"; 

as can see, insert www.bing.com in 2nd array

  char headers[256] = "get /index http/1.1\r\nhost: "+test[100]+"\r\nuser-agent: mozilla/5.0 (compatible; msie 8.0; windows nt 6.0)\r\nreferer: \r\nconnection: close\r\n\r\n"; 

how possible?

char buffer[512]; sprintf(buffer, "get /index http/1.1\r\nhost: %s\r\nuser-agent: mozilla/5.0 (compatible; msie 8.0; windows nt 6.0)\r\nreferer: \r\nconnection: close\r\n\r\n", test); 

buffer contains result want (note how used %s in format string embed test inside http request string)


Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -