- 博客(102)
- 资源 (19)
- 收藏
- 关注

转载 如何成为一名合格的 C/C++ 开发者?
写在前面的话在大多数开发或者准开发人员的认识中,C/C++ 是一门非常难的编程语言,很多人知道它的强大,但因为认为“难”造成的恐惧让很多人放弃。笔者从学生时代开始接触 C/C++,工作以后先后担任过 C++ 客户端和服务器的开发经理并带队开发,至今已经有十多年了。虽然时至今日哪种编程语言对我来说已经不再重要(我目前主要从事 Java 开发),但 C/C++ 仍然是笔者最喜欢的编程语言。在我看来,C/C++ 一旦学成,其妙无穷,就像武侠小说中的“九阳神功”一样,有了这个基础,您可以快速学习任何语言和编程技
2021-06-28 18:49:45
418

原创 道听途说(持续更新)
私有地址和公网地址0 所谓的私有地址就是在互联网上不使用,而被用在局部网络中的地址1 A类地址中的私有地址网段 A类地址范围为:0.0.0.0 - 127.255.255.255 127.0.0.0 - 127.255.255.255 是保留地址用于做循环测试 在A类地址中,10.0.0.0到10.255.255.255是私有地址2 B类地址范围:128.0.0.0到191.255.255.255。 B类地址中的保留地址 169.254.0.0到169.254.255.255是
2021-06-27 13:03:05
216
1

原创 编程学习(持续更新)
编程学习遇到的坑课设:if(a == 1) 落下一个等号 写出 if(a = 1) 导致程序不能正确执行 排查好久解决:可写为if(1 == a) 让编译器去帮你检查 因为if(1 = a)会报错
2021-06-27 12:58:28
117

转载 编程规范转载
对于不同的编程语言来说,具体的编码规范可以有很大的不同,但是其宗旨都是一致的,就是保证代码在高质量完成需求的同时具备良好的可读性、可维护性。例如我们可以规定某个项目的C语言程序要遵循这样的规定:变量的命名,头文件的书写和#include 等等。下面是一些广为采用的编码规范:• GNU Coding Standards • Guidelines for the Use of the C Language in Vehicle Based Software • C++ Coding Guidelin
2021-05-08 23:10:21
174
原创 引用类型变量的大小
int i = 10;int& b = i;你直接去sizeof(b)得到的是int的大小,也就是你引用的数据类型。但其实在内存中引用数据类型是不占空间的。只占一个指针大小。引用的底层可以用指针实现。引用只是C++语言的一个概念而已,而真正怎么去实现是编译器解决的。大多数是通过指针解决。只要先了解引用类型实际占用的内存只有一个指针大小即可。...
2021-09-09 17:23:04
730
原创 MFC动态创建组件代码
int ini_line = 0; char ini_info[50][100]; CEdit* static_lable = new CEdit; static_lable->Create(WS_VISIBLE, CRect(0,0,120,20), this,1); static_lable->SetWindowTextA("CVSLearn-Info"); memset(ini_info,0x00,5000);
2021-09-02 19:10:35
376
原创 MFC实现默认滚动条
添加以下代码在Oninitdlg()函数里 SCROLLINFO scrollinfo; GetScrollInfo(SB_VERT,&scrollinfo,SIF_ALL); scrollinfo.nPage=10; //设置滑块大小 scrollinfo.nMax=100; //设置滚动条的最大位置0–100 SetScrollInfo(SB_VERT,&scrollinfo,SIF_ALL);添加以下函数...
2021-09-02 19:05:40
324
原创 解决MFC按回车键闪退问题
在Dlg类内添加俩个函数CCVSLearn_EXEDlg::OnOK();// 不用实现,空函数即可BOOL CCVSLearn_EXEDlg::PreTranslateMessage(MSG* pMsg);//亦不用实现,空函数即可
2021-09-02 18:47:50
326
原创 MFC主对话框程序只能运行一次
写在App类的Initinstance()函数里HANDLE hMutex = ::CreateMutex(NULL,FALSE,"Small Tool");if (GetLastError() == ERROR_ALREADY_EXISTS){ MessageBoxA(0,"Running...","Error",0); return FALSE;}else{}
2021-09-02 18:43:20
297
原创 控制exe文件只能执行一次
源函数int CCVSLearn_EXEDlg::GetProcessCount(const TCHAR* szExeName){ TCHAR sztarget[MAX_PATH]; lstrcpy(sztarget, szExeName); CharLowerBuff(sztarget, MAX_PATH); int count = 0; PROCESSENTRY32 my; HANDLE l = CreateToolhelp32Snapshot(TH32CS_SNAPPROC
2021-09-02 18:36:17
667
原创 PTA - L1-045 宇宙无敌大招呼
#include <stdio.h>int main(){ char* ch = (char*)malloc(sizeof(char) * 7); scanf("%s",ch); printf("Hello %s\n",ch); return 0;}
2021-08-29 10:18:53
934
原创 动态库文件-demo-21/8/28
DLL.h#pragma once#include <iostream>#include <time.h>#ifdef DLL_DLL#define DLLAPI __declspec(dllexport)#else // !DLLEXPOERS#define DLLAPI __declspec(dllimport)#endif // DLLEXPORTS#ifndef UINT#define UINT unsigned int#endif // !U
2021-08-28 15:52:09
173
原创 MFC按钮编程实例
MFC Cbutton Prog发表之前更换了对话框的图片。更换对话框背景图片单独跑该程序也行。App.h// CVSLearn_wub.h : PROJECT_NAME 应用程序的主头文件//#pragma once#ifndef __AFXWIN_H__ #error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"#endif#include "resource.h" // 主符号// CCVSLearn_wubApp:// 有关此类的实现,请
2021-08-27 13:54:53
365
原创 MFC更换对话框背景图片
添加位图资源bitmap 所以其扩展名为 .bmp而且不能是24位,最好是256色替换代码Onpaint()函数的else语句替换一下代码//CDialog::OnPaint();//要禁止这个调用 CPaintDC dc(this); CRect rect; GetClientRect(&rect); CDC dcMem; dcMem.CreateCompatibleDC(&a
2021-08-27 13:38:36
741
原创 MFC_Button_Prog_Day-21/8/26
// CVSLearn_wubDlg.h : 头文件//#pragma once// CCVSLearn_wubDlg 对话框class CCVSLearn_wubDlg : public CDialogEx{ // 构造public: CCVSLearn_wubDlg(CWnd* pParent = NULL); // 标准构造函数 // 对话框数据 enum { IDD = IDD_CVSLEARN_WUB_DIALOG }; CButton m_button[12];
2021-08-26 16:04:03
255
原创 C/C++编码の注意事项-Neusoft
注意事项No.1#define NUM 10#define NUM 20 //此时NUM为20No.2No.3No.4No.5No.6No.7No.8NO.9No.10No.11
2021-08-24 16:42:53
116
原创 代码规约-Day-21/8/24
数组进行数组间的复制时,需要使用memset_s()函数保证数组的边界安全。memset_s(a,min(sizeof(a),sizeof(b)),b,min(sizeof(a),sizeof(b)));使用边界安全sprintf_s进行字符串格式化处理,不要使用sprintf。sprintf_s(str,256,"%d",x); //多一个buffer使用str***函数(strlen,strcmp,strcat等)时,要确保操作的字符串有结束符’\0’.避免发生内存访问越界问题。进行字
2021-08-24 16:04:39
156
原创 C++的内存管理(Debug和Release模式)
程序内存区域划分内核空间栈内存映射段堆数据段代码段内核空间用户编写的代码无法读取到的内存区域栈(地址顺序向下增长)栈里存放局部变量内存映射段(文件映射,动态库,匿名映射)堆堆里存放New malloc申请到的内存数据段全局数据、静态数据代码段可执行代码 、 只读常量例1#include <iostream>using namespace std;int a = 10;int b; //也可不初始化,但最好初始化int ma
2021-08-24 13:23:14
729
原创 PTA - L1-044 稳赢
#include <iostream>using namespace std;int InNUM = 0;int NumFlag = 0;string InStr = "";string Win(string);string NoWin_NoLose(string);int main(){ cin >> InNUM; while(true) { cin >> InStr; if("End" ==
2021-08-23 07:20:37
213
原创 PTA - L1-043 阅览室
#include <iostream>#include <bits/stdc++.h>using namespace std;struct node{ int id; char key; string time; bool isVaild;//该节点的数据是否有效};//字符串转数字int string_to_integer(string str){ stringstream ss(str); int num;
2021-08-23 07:20:01
208
原创 PTA - L1-042 日期格式化
using System;namespace MySpace{ class MyProgram { static void Main(string[] args) { string[] strs = Console.ReadLine().Split('-'); Console.WriteLine(strs[2] + '-' + strs[0] + '-' + strs[1]);
2021-08-23 07:19:24
248
原创 PTA - L1-041 寻找250
#include <iostream>using namespace std;int result = 0;int InInt = 0;int main(){ for(;;) { cin >> InInt; result += 1; if(250 == InInt) { break; } } cout << res
2021-08-23 07:18:48
365
原创 PTA - L1-040 最佳情侣身高差
#include <iostream>#include <iomanip>using namespace std;char Ch = '0';float Height = 0;unsigned int InNum = 0;int main(){ cin >> InNum; for(size_t i = 0; i < InNum; i++) { cin >> Ch >
2021-08-23 07:18:11
987
原创 PTA - L1-039 古风排版
#include <bits/stdc++.h>using namespace std;int main(){ char a[1100] = { 0 }, temp; int r, c, len; scanf("%d", &r); getchar(); for (int i = 0; (temp = getchar()) != '\n'; i++) { a[i] = temp; len=i+1; } c = (len / r) + (len%r !=
2021-08-23 07:17:34
117
原创 PTA - L1-037 A除以B
#include <iostream>#include <iomanip>using namespace std;float a = 0;float b = 0;float res = 0;int main(){ cin >> a >> b; if (0 == b) { cout << a << "/" << b << "=" << "Error" << end
2021-08-23 07:16:21
154
原创 PTA - L1-036 A乘以B
using System;namespace Myprogram{ class MyCsharp { static void Main() { string[] InStr = Console.ReadLine().Split(); int[] Inint = new int[2]; try { Inint[0] = Conv
2021-08-23 07:15:44
166
原创 PTA - L1-035 情人节
#include <iostream>#include <string>using namespace std;string* Instr = new string[15];int num = 0;int main(){ for (size_t i = 0; i < 15; ++i) { getline(cin, Instr[i]); num += 1; if (Instr[i] == ".") { Instr[i] = "";
2021-08-23 07:15:03
243
原创 PTA - L1-033 出生年
#include <set>#include <iostream>#include <iomanip>using namespace std;int InNum = 0;int Same_Num = 0;int Get_Same_Num(int);int OutAge = 0;int main(){ cin >> InNum >> Same_Num; for (size_t i = InNum; ; ++i) {
2021-08-22 11:35:23
123
原创 PTA - L1-032 Left-pad
#include <iostream>#include <string>using namespace std;int Str_Len = 0;char Fill_Ch = '0';string InStr = "";int main(){ cin >> Str_Len >> Fill_Ch; cin.ignore(); getline(cin, InStr); if (InStr.length() <= Str_Len)
2021-08-22 11:34:50
122
原创 PTA - L1-031 到底是不是太胖了
#include <iostream>#include <string>using namespace std;int InNum = 0;float height = 0;float weight = 0;void Judge_Weight(float height, float weight);int main(){ cin >> InNum; while (InNum--) { cin >> height >>
2021-08-22 11:34:02
130
原创 PTA - L1-030 一帮一
#include <iostream>using namespace std;unsigned int InNum = 0;int main(){ cin >> InNum; int* Sex_Arr = new int[InNum]; string* Name_Arr = new string[InNum]; for (size_t i = 0; i < InNum; i++) { cin.ignore(); cin >> Sex_
2021-08-22 11:33:28
234
原创 PTA - L1-029 是不是太胖了
#include <stdio.h>int main(){ int height = 0; scanf("%d",&height); printf("%.1f\n",(height - 100) * 1.8); return 0;}
2021-08-22 11:32:51
115
原创 PTA - L1-028 判断素数
#include <iostream>#include <cmath>using namespace std;unsigned int InNum = 0;void Is_sNum(int);int main(){ cin >> InNum; int x = 0; while (InNum--) { cin >> x; Is_sNum(x); } return 0;}void Is_sNum(int num){
2021-08-22 11:32:16
174
原创 PTA - L1-027 出租
#include <iostream>#include <set>#include <string>using namespace std;string Instr = "";set<char> mYset;string ChSet = "";string res1 = "int[] arr = new int[]{";string res2 = "int[] index = new int[]{";string resPart = "}
2021-08-22 11:31:41
202
原创 PTA - L1-026 I Love GPLT
#include <iostream>#include <string>using namespace std;string OutStr = "I Love GPLT";int main(){ for(size_t i = 0; i < OutStr.length(); ++i) { cout << OutStr[i] << endl; } return 0;}
2021-08-22 11:30:59
142
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人