A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d9/df0/fast__integer__input_8cpp.html below:

TheAlgorithms/C++: others/fast_integer_input.cpp File Reference

Loading...

Searching...

No Matches

Read integers from stdin continuously as they are entered without waiting for the \n character. More...

#include <iostream>

Go to the source code of this file.

Read integers from stdin continuously as they are entered without waiting for the \n character.

Definition in file fast_integer_input.cpp.

◆ fastinput() void fastinput ( int * number )

Function to read the number from stdin. The function reads input until a non numeric character is entered.

Definition at line 11 of file fast_integer_input.cpp.

11 {

12

13 bool negative = false;

14 int c;

15 *number = 0;

16

17

18 c = std::getchar();

19 if (c == '-') {

20

21 negative = true;

22

23

24 c = std::getchar();

25 }

26

27

28

29 for (; (c > 47 && c < 58); c = std::getchar())

30 *number = *number * 10 + c - 48;

31

32

33

34 if (negative)

35 *(number) *= -1;

36}

◆ main()

Main function

Definition at line 39 of file fast_integer_input.cpp.

39 {

40 int number;

42 std::cout << number << std::endl;

43 return 0;

44}

void fastinput(int *number)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4