C++基本语法( Visual Studio 2015 )【个人 见解】
對于C++這門語言,對于初學者的小編而言,是門很強大且有發展空間的語言。它囊括C語言,可以說是全部的功能語法,也可以說是很有獨特性的語言之一。
用強大已不足以形容,它能干的事情太多,可以廣泛用于開發軟件、游戲編程...
它跟C語言的語法大相徑庭,或許有人會問到底先學C語言好,還是C++語言好呢?
作為過來者的小編,這樣認為的:
想從事C++語言發展的你,個人建議最好先把C語言學會,不需要研究的多么深徹,只要能做到連貫使用即可。因為再去學習C++語言時,你就會發覺它們的相似之處很多,可以這樣說學會C語言,C++語言已經學會了一半。
int main()
{
int number = 0;
cin >> number;
cout << "你輸入的數字是:" << number << endl;
system("pause");
return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
string srcstr = "visiousdragon";
cout<<srcstr.c_str()<<endl;
system("pause");
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char destStr[] = { 0 };
char sourceStr[] = "visiousdragon";
strcpy(destStr, sourceStr);
cout << destStr << endl;
system("pause");
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char destStr[] = "visious";
char sourceStr[] = "dragon";
strcat(destStr, sourceStr);
cout << destStr << endl;
system("pause");
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int number = 0;
}
打印的結果為:destStr相等于sourceStr,不難總結出以下三個設定: destStr=sourceStr,返回=0 destStr>sourceStr,返回>0 destStr<sourceStr,返回<0 4.strlen()#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int number = 0;
char destStr[] = "visiousdragon";
number = strlen(destStr);
cout << "destStr字符串字符個數為:" << number << endl;
system("pause");
return 0;
}
轉載于:https://blog.51cto.com/12829190/2371792
總結
以上是生活随笔為你收集整理的C++基本语法( Visual Studio 2015 )【个人 见解】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: redis-rdb-tool 工具介绍
- 下一篇: React Bind Handle的思考