Question
Hello this is C programming I am working through Udemy tutorial but am getting confused with why instead of passing a pointer as the definition
Hello this is C programming I am working through Udemy tutorial but am getting confused with why instead of passing a pointer as the definition suggest below in #2(everything works I am just trying to understand with deeper understanding instead of following blindly why it works in this manner) we pass a function http_server_jquery_handler instead of (*http_server_jquery_handler). This is confusing because the second parameter seems to follow the synatx correctly as (httpd_req_t *r) is essentially the same as (httpd_req_t *req). Why doesnt the first part follow the synatx?
#1
Below is the definition of the .handler data member of the struct httpd_uri_t
#2
httpd_uri_t jquery_js ={ . uri ="/ jquery-3.3.1.min.js", . method = HTTP_GET, . handler = http_server_jquery_handler, .user_ctx = NULL /** Handler to call for supported request method. This must return ESP_OK, or else the underlying socket will be closed / esp_err_t (*handler)(httpd_req_t r); static esp_err_t http_server_jquery_handler(httpd_req_t req) \{ ESP_LOGI(TAG, "Jquery requested"); httpd_resp_set_type(req, "application/javascript"); //Notice h httpd_resp_send(req, (const char*) jquery_3_3_1_min_js_start, jqu return ESP_OK; httpd_uri_t jquery_js ={ . uri ="/ jquery-3.3.1.min.js", . method = HTTP_GET, . handler = http_server_jquery_handler, .user_ctx = NULL /** Handler to call for supported request method. This must return ESP_OK, or else the underlying socket will be closed / esp_err_t (*handler)(httpd_req_t r); static esp_err_t http_server_jquery_handler(httpd_req_t req) \{ ESP_LOGI(TAG, "Jquery requested"); httpd_resp_set_type(req, "application/javascript"); //Notice h httpd_resp_send(req, (const char*) jquery_3_3_1_min_js_start, jqu return ESP_OK
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started