jazykc
2013.3
upoljazykc
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Macros
Pages
prace-s-preprocesorem
nacteni-cisla-typu-int.c
Go to the documentation of this file.
1
25
//Povolené knihovny:
26
#include <stdio.h>
27
#include <stdlib.h>
28
34
#define cti_int(k)\
35
(scanf("%i", &(k)), (k))
36
// ^--- operator carka!
37
38
#define cti_int2(s, k)\
39
(printf("%s",(s)?(s):"Zadej cele cislo:"),scanf("%i", &(k)), (k))
40
47
#define flushget() while(getchar()!='\n')
48
49
int
main(
void
) {
50
int
j, k;
51
int
inty[5];
52
int
*pi=inty;
53
char
*s = NULL;
54
55
//honza: boze, priklad jak noha, na konci kurzu ZP2, :(
56
printf(
"Zadejte cele cislo: "
);
57
if
((j =
cti_int
(k)) == 0) printf(
"nula\n"
);
//nula hlasi i pri vadnem vstupu!!!
58
else
printf(
"%i %i\n"
, j,k);
59
60
//NOTE: pokud je predchozi cti_int() volan s neplatnymi/prebyvajicimi daty!!!
61
//je treba po scanf() zbytek zahodit!!! treba pomoci fgets()? gets() -- nepouzivat!!!
62
flushget
();
63
j = cti_int2(
""
, k); printf(
"%d %d\n"
, j, k);
64
j = cti_int2(NULL, inty[0]); printf(
"%d %d\n"
, j, inty[0]);
65
j = cti_int2(NULL, *pi); printf(
"%d %d\n"
, j, inty[0]);
66
67
if
(s && *s) { printf(
"s==NULL\n"
); }
68
69
//co kdyz int pretece, hlasi scanf neco? ne, scanf() vraci pocet zpracovanych %x
70
j = sscanf(
"12345678901234567890"
,
"%i"
, &k); printf(
"scanf()=> %d i=%i\n"
, j, k);
71
72
return
EXIT_SUCCESS;
73
}
flushget
#define flushget()
Definition:
nacteni-cisla-typu-int.c:47
cti_int
#define cti_int(k)
Definition:
nacteni-cisla-typu-int.c:34
Generated on Sat Dec 7 2013 22:57:26 for jazykc by
1.8.5