summaryrefslogtreecommitdiff
path: root/iup/test/scanf.c
blob: 2ea766329601d994753a9d3e769a86e95d7c49c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdlib.h>
#include <stdio.h>
#include "iup.h"

void ScanfTest(void)
{
  int ret;
  int integer = 12;
  float real = 1e-3f;
  char text[300]="This is a vector of characters";
  char *fmt =
  {
   "IupScanf Example\n"
   "Text: %300.5%s\n"
   "Real: %20.10%g\n"
   "Integer: %20.10%d\n"
  };
  
//  IupSetLanguage("ENGLISH");

  ret = IupScanf(fmt, text, &real, &integer);
  if (ret == -1)
    IupMessage("IupScanf","Operation canceled");
  else
    IupMessagef("IupScanf","Text: %s\nReal: %f\nInteger: %d\nFields read successfully: %d",text,real,integer,ret);
}

#ifndef BIG_TEST
int main(int argc, char* argv[])
{
  IupOpen(&argc, &argv);

  ScanfTest();

  IupClose();

  return EXIT_SUCCESS;
}
#endif