#include <newt.h>
#include <stdlib.h>
#include <stdio.h>
void main(void) {
newtComponent form, checkbox, rb[3], button;
char cbValue;
int i;
newtInit();
newtCls();
newtOpenWindow(10, 5, 40, 11, "Checkboxes and Radio buttons");
checkbox = newtCheckbox(1, 1, "A checkbox", ' ', " *X", &cbValue);
rb[0] = newtRadiobutton(1, 3, "Choice 1", 1, NULL);
rb[1] = newtRadiobutton(1, 4, "Choice 2", 0, rb[0]);
rb[2] = newtRadiobutton(1, 5, "Choice 3", 0, rb[1]);
button = newtButton(1, 7, "Ok");
form = newtForm(NULL, NULL, 0);
newtFormAddComponent(form, checkbox);
for (i = 0; i < 3; i++)
newtFormAddComponent(form, rb[i]);
newtFormAddComponent(form, button);
newtRunForm(form);
newtFinished();
/* We cannot destroy the form until after we've found the current
radio button */
for (i = 0; i < 3; i++)
if (newtRadioGetCurrent(rb[0]) == rb[i])
printf("radio button picked: %d\n", i);
newtFormDestroy(form);
/* But the checkbox's value is stored locally */
printf("checkbox value: '%c'\n", cbValue);