什么是C中的重要概念,你没有从你的老师学习 [英] What are the important notions in C that you did not learn from your teachers

查看:193
本文介绍了什么是C中的重要概念,你没有从你的老师学习的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在9月,我会给基于C我第一次讲课的学生在工程学校(通常是我教数学和信号处理,但我也做了很多用C实际工作中,不给演讲)。计算机科学是不是他们的主要话题(他们更学习电子和信号处理),但他们需要在编程好的背景(其中一些将可能成为软件开发商)

In September, I will give my first lectures on C to students in engineering school (usually I teach math and signal processing, but I have also done a lot of practical work in C, without giving the lectures). Computer science is not their main topic (they are more studying electronics and signal processing), but they need to have a good background in programming (some of them will maybe become software developers)

今年将是学习C的他们的第二年(他们应该知道什么是指针,以及如何使用它,当然,这个概念还没有被同化)

This year will be their 2nd year of learning C (they are supposed to know what a pointer is and how to use it, but of course, this notion is not yet assimilated)

在除了经典的东西(数据结构,经典算法,...),我可能会关注一些我的演讲:
- 设计算法(它在伪code写的)的 的编码在C之前(考虑编码之前)
- 让你的code可读(注释,变量名,...)

- 三分球,三分球,三分球! (它是什么,如何以及何时使用它,内存分配等)

In addition to the classical stuff (data structures, classical algorithms, ...), I will probably focus some of my lectures on: - design the algorithm (and write it in pseudo-code) before coding it in C (think before coding) - make your code readable (comments, variable names, ...) and - pointers, pointers, pointers ! (what is it, how and when to use it, memory allocation, etc...)

根据你的经验,什么是C中的最重要的概念,你的老师从来没有教过你吗?在哪些特定的点,我应该集中?

例如,我应该向他们介绍一些工具(皮棉,...)?

For example, should I introduce them to some tools (lint, ...) ?

推荐答案

在三分球方面常量关键字的使用:

Use of const keyword in pointers context :

下面的声明之间的区别:

The difference between following declarations :

 A)   const char* pChar  // pointer to a CONSTANT char  
 B)   char* const pChar  // CONSTANT pointer to a char  
 C)   const char* const pChar  // Both

因此​​,与答:

So with A :

const char* pChar = 'M';
*pChar = 'S'; // error : you can't modify value pointed by pChar

和与乙:

char OneChar = 'M';
char AnotherChar = 'S';
char* const pChar = &OneChar;
pChar = &AnotherChar; // error : you can't modify address of pChar

这篇关于什么是C中的重要概念,你没有从你的老师学习的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆