![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
小白地瓜
这个作者很懒,什么都没留下…
展开
-
C++实现TCP简单的socket服务端和客户端
1、服务端#include <iostream>#include <sys/socket.h>#include <netinet/in.h>#include <unistd.h>#include <string.h>#define PORT 8111#define MESSAGE_LEN 1024 // 消息的长度int main(int argc, char* argv[]){ // 创建socket int sock原创 2022-01-08 02:00:22 · 3405 阅读 · 0 评论 -
C++实现一个最简单的服务器
一、 文件分为:main.cppserver.cppserver.h二、代码main.cpp#include <iostream>#include "server.h"int main(int argc, char* argv[]){ avdance::Server* server = new avdance::Server(); if (server) { server->run();原创 2022-01-03 20:31:11 · 3147 阅读 · 0 评论 -
error C4996: ‘strcpy‘: This function or variable may be unsafe. Consider using strcpy_s instead
出现这个错误时,是因为strcpy函数不安全造成的溢出。解决方法是:找到【项目属性】,点击【C++】里的【预处理器】,对【预处理器】进行编辑,在里面加入一段代码:_CRT_SECURE_NO_WARNINGS。原创 2021-11-20 00:21:46 · 935 阅读 · 0 评论 -
C++,基本内置类型
基本内置类型C++定义了一套包括算数类型和空类型在内的基本数据类型,其中算数类型包含了字符,整型数,布尔值和浮点数。空类型不对应具体的值,仅用于一些特殊情况,例如,当函数不返回任何值的时使用空类型作为返回类型。1、算数类型类型含义最小格式bool布尔类型未定义char字符8位wchar_t宽字符16位char16_tUnicode字符16位char32_tUnicode字符32位short短整型16位int整型16位原创 2021-08-11 00:04:52 · 71 阅读 · 0 评论 -
C++,if语句
#include <iostream>int main() { int a = 0, b = 1; int c; while (std::cin >> c) if ( c >= (a+b)) std::cout << c << std::endl; else{ std::cout << a + b << std::endl; }}格式为:if(条件) 执行代码;else{原创 2021-08-10 23:34:30 · 89 阅读 · 0 评论 -
c++ 控制流;
while语句while语句反复执行一段代码,直至给定条件为假为止。#include <iostream>int main() { int a = 0, b = 1; while (b <= 10) { a += b; ++b; } std::cout << "1至10的累和为:" << a << std::endl; return 0;}for语句#include <iostream>int ma.原创 2021-08-10 00:31:57 · 100 阅读 · 0 评论 -
c++,输入输出;
#include <iostream>int main() { std::cout << "=======" << std::endl; int v1, v2 = 0; std::cin >> v1 >> v2; std::cout << v1 + v2 << std::endl; return 0;}使用iostream库,该库包含两个基础类型istream和ostream,分别对应输入流和输出流,一原创 2021-08-10 00:13:46 · 50 阅读 · 0 评论