-
Notifications
You must be signed in to change notification settings - Fork 10
chl_getf
it4e edited this page Apr 16, 2016
·
3 revisions
<chl/chl.h>
chl_getf, CHL GET float
float chl_getf(char * name);
The chl_getf function is used to fetch the value converted to a float of the GET method variable [name].
- name: the name of the GET variable
On success: GET variable value converted to float, 0 if GET variable is not defined or -1 if conversion to float could not be done.
Call CHL controller file 'index.chl' with GET parameters (num1=40.2, num2=10.8)
index.chl?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_getf("num1") + chl_getf("num2");
printf("The sum of %s + %s = %f", chl_get("num1"), chl_get("num2"), sum);
}
Output: The sum of 40.2 + 10.8 = 51