![](https://img-blog.csdnimg.cn/20190828185331852.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
c语言
刘拉拉的book
这个作者很懒,什么都没留下…
展开
-
fwrite ,fprintf的作用与区别
1.概念和作用fwrite是C语言函数,指向文件写入一个数据块,通常是数组或结构体。fprintf是C/C++中的一个格式化写-库函数,其作用是格式输出到一个流/文件中.2.用法fwrite 函数示例一:/* fwrite example: write buffer */#include "stdafx.h"#include <stdio.h>int main(int argc, char* argv[]){ FILE * pFile; char bu转载 2020-05-26 10:22:53 · 1514 阅读 · 0 评论 -
Getmemory函数详解--内存操作的理解
题目:void GetMemory(char *p){p = (char *)malloc(100);}void Test(void){char *str = NULL;GetMemory(str);strcpy(str, “hello world”);printf(str);}请问运行Test 函数会有什么样的结果?分析:程序崩溃。因为GetMemory 并不能传递动态内存,Test 函数中的 str 一直都是 NULL。strcpy(str, “hello world”);将使程转载 2020-05-14 15:43:15 · 2608 阅读 · 0 评论 -
结构体的补齐与对齐
首先我们先看看下面的C语言的结构体:typedef struct MemAlign { int a; char b[3]; int c; }MemAlign; 以上这个结构体占用内存多少空间呢?也许你会说,这个简单,计算每个类型的大小,将它们相加就行了,以32为平台为例,int类型占4字节,char占用1字节,所以:4 + 3 + 4 = 11,...转载 2019-10-29 15:51:45 · 533 阅读 · 0 评论 -
结构体指针与结构体变量
看一个例子来了解Struct_learn.h#ifndef __STRUCT_LEARN__ //if not define宏定义判断,作用是防止多重定义#define __STRUCT_LEARN__ #include <stdlib.h>#include <string.h>struct a{ int value1; char value...原创 2019-08-26 16:16:38 · 273 阅读 · 0 评论 -
C语言运算符优先级列表和口诀
转自:https://blog.csdn.net/qq_40443457一共有十五个优先级:1 () [] . ->2 ! ~ -(负号) ++ – &(取变量地址)* (type)(强制类型) sizeof3 * / %4 + -5 >> <<6 > >= < <=...转载 2019-06-17 11:14:22 · 166 阅读 · 0 评论 -
C基本数据类型所占字节数
转自:https://blog.csdn.net/business122/article/details/813581151字节=8位1k=1024字节=2^101m=1024k1g=1024m买硬盘实际内存小是因为厂商当1000换算的。这个基本的问题,很早以前就很清楚了,C标准中并没有具体给出规定那个基本类型应该是多少字节数,而且这个也与机器、OS、编译器有关,比如同样是在32b...转载 2019-05-14 17:02:34 · 344 阅读 · 0 评论 -
c语言:使用指针变量传递地址
转自:http://www.slyar.com/blog/c-swap-pointer.html初学者经常的一个误区:#include <stdio.h>void swap(int x,int y)//这是错误的写法{int temp;temp=x;x=y;y=temp;}int main(){int a=5,b=8;swap(a,b);printf("...转载 2019-04-25 15:42:53 · 1545 阅读 · 1 评论