Go Down

Topic: Including Variable in client.write? (Read 731 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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy