Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib>
- #include<cstring>
- using namespace std;
- //主程式
- int main()
- {
- int a = 1023; //宣告變數
- float b =23.45;
- char *str = "菜牛牛\n";
- //輸出字串內容
- cout << str;
- //輸出整數,浮點數和運算式
- cout << "a = " << a << endl; //endl 換行 意思
- cout << "b = " << b << endl;
- cout << "a + b = " << a+b << endl;
- cout.put('a'); //put()成員函數
- cout.put('b').put('c');
- cout << endl;
- cout << strlen(str) << endl; //字串長度
- cout.write(str, 2); //write()成員函數
- cout << endl;
- cout.write(str,strlen(str)-1);
- cout.write(str,strlen(str));
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement