#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); whats this mean??why ios???

217 views
Skip to first unread message

namans...@gmail.com

unread,
Dec 18, 2018, 10:55:54 PM12/18/18
to C++ GCU Forum
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second


int32_t main()
{
    IOS;
    int n,c;
    cin>>n>>c;
    .
     .
    . 
     .
  }



ios mean here?????? and int 32_t mean???

zoso

unread,
Nov 2, 2020, 10:15:22 PM11/2/20
to C++ GCU Forum
IOS is a macro. Macros are simple text expansions. As in the above example, you can see that there's the line

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

So when it's used in

int32_t main() {
IOS;

that IOS is just substituted with the #define IOS expansion and it shall thus become:

int32_t main() {

ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);;

The 'ios' in ios::sync_with_stdio is a class in the <ios> header file of C++ library. (https://en.cppreference.com/w/cpp/io/ios_base)

Now coming to the other half. int32_t is a "fixed-width" integer type defined in <cstdint> header file. You would've normally seen 'int a = 5;' being used. One problem with that statement is that there's no guarantee as to what would be the size of 'int' on various platforms. It can be 2 bytes (16 bits) or 4 bytes (32 bits) depending on what Operating System one is executing the program on. To avoid this uncertainty. one can use fixed-width integer types like int32_t which indicates that irrespective of the platform, that variable will always be of 32-bits (or 4 bytes).
Reply all
Reply to author
Forward
0 new messages