当前位置: 首页 > news >正文

Programming abstractions in C阅读笔记:p76-p83

《Programming Abstractions In C》学习第42天,p76-p73总结。
一、技术总结
1.数组和指针
在C语言中,数组和指针非常相似,相似到必须将它们同时考虑,当看到数组就应该想到指针,当看到指针就应该想到数组。示例:

#include <stdio.h>int SumIntegerArray(int array[], int n);
int SumIntegerArray2(int *array, int n);/** SumIntegerArray:数组求和,数组用法
*/
int SumIntegerArray(int array[], int n) {int i, sum;sum = 0;for (i = 0; i < n; i++) {sum += array[i];}return sum;}/** SumIntegerArray2:数组求和指针用法
*/
int SumIntegerArray2(int *ip, int n) {int i, sum;sum = 0;for (i = 0; i < n; i++) {sum += *ip++;}return sum;}
void main() {int aSum, pSum;int array[] = {1, 2, 3, 4, 5};aSum = SumIntegerArray(array, 5);printf("对数组[1, 2, 3, 4, 5]求和: aSum=%d\n", aSum);pSum = SumIntegerArray2(array, 5);printf("对数组[1, 2, 3, 4, 5]求和: pSum=%d\n", aSum);
}

那么数组和指针有什么不同呢?声明的时候内存分配不一样。示例:

#include <stdio.h>void main() {int array[5];int *p;printf("%lu\n", sizeof(array)); //20, int类型占4bytes,5个元素占20个bytesprintf("%lu\n", sizeof(p)); //8, 64位的电脑}

二、英语总结
1.difference和distinctiond的区别?
答:网上查找了一番,对于各种回答还是不大满意,先记着:
(1)stack exchange:
“Difference” is a much more generic work just referring to set of attributes that are different between two or more things in a set. “Distinction” is much more specific and often separates ONE item above and beyond the other differences in a set. E.g:All people have differences, but some have the distinction of being famous.
三、参考资料
1.编程
1)Eric S.Roberts,《Programming Abstractions in C》:https://book.douban.com/subject/2003414
2.英语
1)Etymology Dictionary:https://www.etymonline.com
2)Cambridage Dictionary:https://dictionary.cambridge.org
3)Merrian-Webster Dictionary:https://www.merriam-webster.com
4)Collins Dictionary:https://www.collinsdictionary.com
5)Oxford Dictionary:https://www.oxfordlearnersdictionaries.com
6)The Free Dictonary:https://www.thefreedictionary.com
7)Urban Dictionary:https://www.urbandictionary.com

欢迎搜索及关注:编程人(a_codists)

http://www.lryc.cn/news/114227.html

相关文章:

  • 已解决(三个问题)|neo4j Failed authentication attempt for ‘meter‘ from 127.0.0.1
  • neo4j查询语言Cypher详解(二)--Pattern和类型
  • 动态规划(用空间换时间的算法)原理逻辑代码超详细!参考自《算法导论》
  • Jmeter添加cookie的两种方式
  • 【ArcGIS Pro二次开发】(58):数据的本地化存储
  • React配置代理服务器的5种方法
  • 树莓派:5.jar程序自启运行
  • Vivado中SmartConnect和InterConnect的区别
  • 了解HTTP代理日志:解读请求流量和响应信息
  • 排序-堆排序
  • 挑战Open AI!!!马斯克宣布成立xAI.
  • HTTP协议学习笔记1
  • 【网络基础实战之路】基于OSPF协议建立两个MGRE网络的实验详解
  • 【学习日志】2023.Aug.6,支持向量机的实现
  • LeetCode_动态规划_中等_1749.任意子数组和的绝对值的最大值
  • 无涯教程-Perl - 环境配置
  • QT显示加载动画
  • 原型模式(C++)
  • web浏览器打开本地exe应用
  • 微信小程序如何配置并使用less?
  • 【Spring】反射动态修改Bean实例的私有属性值
  • MySQL DDL 数据定义
  • Ventoy 设置VTOY_MAX_SEARCH_LEVEL = 0只扫描U盘根目录 不扫码子目录
  • vue3父子同信的双向数据实现
  • Shiro是什么?为什么要用Shiro?
  • Vue3+Vite+Pinia+Naive后台管理系统搭建之九:layout 动态路由布局
  • 从零开始学Python(Ⅰ)基本变量与数据类型
  • SQL ASNI where from group order 顺序 where和having,SQL底层执行原理
  • Mac M2 Ventura(13.3) 新机 安装Cocoapods
  • Unity 引擎做残影效果——2、屏幕后处理方式