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