Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned long int getNumber(TParams *pParams)
- {
- unsigned long int cislo = 0;/** inicializacia návratového čisla z funkcie */
- while (true)
- {
- char c = getchar();
- if (c == ' ')
- continue;
- if (c == '\n' || c == EOF)
- break;
- if (c < '0' || c > '9')
- {
- pParams->ecode = EVALUE;
- return 0;
- }
- if (cislo > ULONG_MAX / 10 || ((cislo == ULONG_MAX / 10) &&
- ((unsigned long int)(c - '0') > (ULONG_MAX - (ULONG_MAX / 10) * 10))))
- {
- pParams->ecode = EOVERFLOW;
- return 0;
- }
- cislo = cislo * 10 + c - '0';
- }
- return cislo;
- }
Add Comment
Please, Sign In to add comment