cpp输入输出,类型,函数

ios_base::sync_with_stdio(false);//这个函数是一个“是否兼容stdio”的开关
cin.tie(0);//解除cin与cout的绑定

用字符读入比数字读入快?


//cf 有毒,能用long long 就用long long 
//规定 sizeof(int)<=sizeof(long int )<=sizeof(long long int )
#include<iostream>
using namespace std;
int main(){
    cout<<sizeof(long long int )<<endl;
    cout<<sizeof(long int )<<endl;
    return 0;
}

//output
//8
//4
long int a=1;
a<<=63;
long int a = 1L<<63;

有效,只有加了L下标的才认为是long int 数,其他默认是int 数。


计算log,用换底公式

log
Compute natural logarithm (function )

log10
Compute common logarithm (function )
--------

char * fgets ( char * str, int num, FILE * stream );

istream& getline (char* s, streamsize n );
istream& getline (char* s, streamsize n, char delim );

A newline character makes fgets stop reading, but it is considered a valid character by the function and included in the string copied to str. fgets有

The delimiting character is the newline character ('\n') for the first form, and delim for the second: when found in the input sequence, it is extracted from the input sequence, but discarded and not written to s. getline 没


利用stringstream from sstream 类型转换

tellp
Get position in output sequence (public member function )
seekp
Set position in output sequence (public member function )
clear//读完了要请flags
Set error state flags (public member function )
tellp
Get position in output sequence (public member function )
seekp
Set position in output sequence (public member function )
str//用来清除内容传“”
Get/set content (public member function )


fgets
char * fgets ( char * str, int num, FILE * stream );

(1)

istream& getline (istream& is, string& str, char delim);

(2)

istream& getline (istream& is, string& str);

Get line from stream into string
Extracts characters from is and stores them into str until the delimitation character delim is found (or the newline character, '\n', for (2)).

The extraction also stops if the end of file is reached in is or if some other error occurs during the input operation.

If the delimiter is found, it is extracted and discarded (i.e. it is not stored and the next input operation will begin after it).

Note that any content in str before the call is replaced by the newly extracted sequence.

Each extracted character is appended to the string as if its member push_back was called.

转载于:https://www.cnblogs.com/xsthunder/p/6657688.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值