Reading long int using scanf

前端 未结 5 2223
栀梦
栀梦 2021-02-13 00:51

To read an int using scanf we use:

scanf(\"%d\", &i);

What if i is a long not int??

5条回答
  •  忘掉有多难
    2021-02-13 01:38

    scanf("%ld", &i);
    

    You can also use "%Ld" for a long long (and depending on your compiler, sometimes also "%lld").

    Take a look at the Conversions section of the scanf man page for more. (Just Google it if your system doesn't have manpages).

提交回复
热议问题