Hi everyone I want to develop a web server using the cygnal 8051 mcu, but I want to know how can I declare a varible or array for the next data: Data "HTTP/1.0 200 OK" , $0d , $0a Data "Content-type: text/html" , $0d , $0a , Data "<html><head><title>Test </head>" please someone who know how to declare a global variable to put in this variable, strings, constant and how is the best way to pointer to this variable too maybe can be : unsigned data webpage [] = " ..." is it ok?? thanks for the help
In C, strings are arrays of characters ("char"). If you intend to use the C library string-handling functions, they should always be null-terminated, which is to say they need one extra byte at the end with value 0 to mark the end of the string. Literal strings in C (surrounded by double quotes) have type pointer-to-char (char*), and include the null termination. You can insert arbitrary characters into a C literal string with the backslash \ escape operator. Commonly-used characters like CR and LF have special codes. You may or may not need to access your string constant line-by-line. Perhaps you can treat it as one long string. As one long string,
char* webpage = "HTTP/1.0 200 OK\r\l" "Content-type: text/html\r\l" "<html><head><title>Test </head>";
char* webpage[] = { "HTTP/1.0 200 OK\r\l", "Content-type: text/html\r\l", "<html><head><title>Test </head>" };
Thanks For the help Drew I learn C but about arrays I don't know very much. You say the char *webpage is a array of pointers and how can I use it?? and if I want to write this strings in the code space how can I read then.. please explain more about that Thanks very much
char* webpage[]
extern void SendToBrowser (char* p); U8 i; for (i = 0; i < NumLinesInWebHeader; ++i) { SendToBrowser (webpage[i]); }
char const code stringConstant[] = "my string";
Just a note about arrays and variables. In fact , in ANSI C next lines are different: unsigned char array[] = "test"; unsigned char *array = "test"; First line allocates just 5 bytes; second line allocates 5 bytes for the string + some (2/4/?) bytes for the pointer to this string.