Go Down

Topic: Including Variable in client.write? (Read 790 times) previous topic - next topic

gibbon

Oct 12, 2012, 10:11 am Last Edit: Oct 12, 2012, 10:15 am by gibbon Reason: 1
Hi, this is the bit i always get confused with when programming in C (this isnt my primary language). Im using the ethernet shield that simply outputs some html like so:

client.write("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<html><head></head><body>HELLO</body></html>\r\n\r\n");

I want to include a string (or equivilent) into that output?

What does it have to be? ive tried a string,char array, tried converting string.toCharArray(Buf) but what ever i do it fails?

NOTE: Just found the client.print that seems to accept all whihc make life alot easier. Whats the difference or advantages of using client.write or client.print?

Hope you can help
Thanks
Andy

bubulindo

Code: [Select]


client.write("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<html><head></head><body>HELLO</body></html>\r\n\r\n");

or

client.write("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<html><head></head><body>HELLO, my var is:");
client.write(myVar);
client.write("</body></html>\r\n\r\n");
This... is a hobby.

Go Up