c/c++
freeonsky
这个作者很懒,什么都没留下…
展开
-
在数组中保存/获取 指针
原理使用memcpy 复制指针内容到数组#include <cstdio>#include <cstdlib>#include <cstring>// 测试在int数组中保存/获取 指针int main(){ int arr[10]; int *p = (int *)malloc(3 * sizeof(int)); ...原创 2020-03-25 11:30:37 · 421 阅读 · 1 评论 -
strtok注意事项
问题最近使用strtok函数分割字符串,代码异常退出,报段错误。错误代码如下#include "string.h"#include <stdio.h>int main(){ char *a = "ni hao wos s sd"; // 错误做法 // char a[] = "ni hao wos s sd"; // 正确做法 char *b = s...原创 2020-03-22 12:06:48 · 392 阅读 · 0 评论 -
自己动手写bootloader
自己动手写bootloader环境准备开发操作系统:Ubuntu 18.04所需软件apt install bochs bochs-x nasm build-essential写 bootloaderboot.asm 代码; filename boot.asmorg 7c00h ; bis start address; int 10 mov ax, csmo...原创 2020-03-08 16:55:44 · 376 阅读 · 1 评论 -
ubuntu 18.04 下 nasm 写hello world
hello world代码; 编译:; 1, nasm -f elf64 hello.asm 如果是32位系统则 nasm -f elf32 hello.asm; 2, gcc -no-pie hello.osection .textglobal mainmain: mov eax,4 ;4号调用 mov ebx,1 ;ebx送1表示输出 mov ecx,m...原创 2020-03-08 16:51:32 · 403 阅读 · 0 评论 -
tchar.h 与windows.h同时使用时的注意事项
在写windows程序时,一般会引用tchar.h 与windows.h连原创 2014-07-11 23:04:08 · 1861 阅读 · 0 评论 -
cat 021 解析
cat 021 解析把 https://blog.csdn.net/qingfengleerge/article/details/81102854#commentBox 代码改了下,不依赖vs,去掉windows.h头文件,只使用c++标准库,使得代码可以直接使用gcc编译。代码如下:// cat021_test_1.cpp : 定义控制台应用程序的入口点。//使用C++对网络数据包进...原创 2019-04-29 16:43:23 · 3864 阅读 · 0 评论 -
使用c++统计pv uv
使用c++读取日志统计pv uv使用c++读取日志统计pv uv代码代码思路使用c++读取日志统计pv uv在linux系统下通过c++读取日志文件,统计pv uv。代码main.cpp 文件如下, 执行下面命令编译g++ -o sumary main.cpp#include <iostream>#include <vector>#include <s...原创 2019-06-29 20:29:07 · 225 阅读 · 0 评论