-
Notifications
You must be signed in to change notification settings - Fork 10
chl_postf
it4e edited this page Apr 17, 2016
·
3 revisions
<chl/chl.h>
chl_postf, CHL POST float
float chl_postf(char * name);
The chl_postf function is used to fetch the value converted to a float of the POST method variable [name].
- name: the name of the POST variable
On success: POST variable value converted to float, -1 if variable is not defined, if conversion to float could not be done or if an error occurred.
Call CHL controller file 'index.chl' with POST parameters (num1=40.2, num2=10.8)
POST index.chl HTTP/1.1
num1=40.2&num2=10.8
main.c
#include <chl/chl.h>
#include <stdio.h>
int main() {
float sum;
chl_set_default_headers();
chl_print_headers();
sum = chl_postf("num1") + chl_postf("num2");
printf("The sum of %s + %s = %f", chl_post("num1"), chl_post("num2"), sum);
}
Output: The sum of 40.2 + 10.8 = 51