?? cpp1.cpp
字號:
#include<iostream.h>
#include<string.h>
void print(char *s);
void main()
{
//cout
cout<<'k'<<'a'<<'n'<<'g'<<endl;
cout.put('k').put('a').put('n').put('g').put('\n');
char c1='k', c2='a', c3='n', c4='g';
cout.put(c1).put(c2).put(c3).put(c4).put('\n');
char *str="I love you kang .";
cout<<"The string is \""<<str<<"\""<<endl;//由于是雙斜線出現在字符數組中 ,而它又使定界符,故用反斜線\" 表示
print(str);
//cin2 getline() find the Input max strings
static const int SIZE=80;
char buf[SIZE];
int lcnt=0,lmax=-1;
cout<<"Input ...\n";
while(cin.getline(buf,SIZE))
{
int count= cin.gcount();//該函數的功能是返回上一次從輸入流中實際讀取的字符個數,包含空白符
lcnt++;
if(count>lmax)
lmax=count;
cout<<"Line #"<<lcnt<<':'<<'\t'<<count<<endl;
cout.write(buf,count).put('\n').put('\n');
}
cout<<endl;
cout<<"Longest line:"<<lmax<<endl;
cout<<"Total line:"<<lcnt<<endl;
//cin3
char ch;
cout<<"Enter characters:";
while((ch=cin.get())!=EOF||ch=='\n')
cout.put(ch).put('\t');
//cin
static const int N=40;
char s1[N],
s2[N];
cout<<"Enter a strings:"<<endl;
cin>>s1;
cout<<"s1="<<s1<<endl;
cin.get(s2,N);
cout<<"s2 = "<<s2<<endl;
}
void print(char *s)
{
cout.write(s,strlen(s)).put('\n');
cout.write(s,6)<<'\n';
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -