EECS2031 Software Tools

2016-09-12 14:44:06

[专业笔记] , , ,

This course introduces very very fundamental C/shell programming skills on linux.

We are using C89 standard in this  EECS 2031 course. That means you cannot declare the iterator variable in a for loop. And you should be very careful when you are trying to copy any C code from Google or Stack Overflow. Because those code fragments might be written in C with C99 standard or Cpp. Professor is very nice but TAs are not that efficient. We have to wait a long time for the grading.

The course title is "Software Tools". The most difficult thing is you do not even have a "tool" in this course to write your code. You have to figure out which tools to use. I would recommend the gedit in the lab. And Makefile is also a very good tool. In your PC or laptop, you can use whatever you want, but to be noticed that XCode is using C99 standard and your computer might have other compilers.

 

September 12
LAS 2004

New yuan
Professor UT
email: utn ### cse.yorku.ca (在邮件的开头写上  EECS 2031 - )
2003在多大毕业;2002年开始在YorkU教学;多次担任这门课的教学任务,network、wireless、IT security 相关的领域,研究生相关方面可以联系这位教授

课本使用 C Programming language

Practise UNIX 方面那本书可以去图书馆借来看看

lab test 的lab才算分,别的lab可以上传script提供给lab test 使用,所用的lab都使用lab test environment

无垃圾回收

No String

EOF is equal to -1

In C, Pass-by-reference is simulated by passing the address of a variable (a pointer) and dereferencing that address within the function to read or write the actual variable. This will be referred to as "C style pass-by-reference."

source http://www-cs-students.stanford.edu/~sjac/c-to-cpp-info/references

 


September 19

c language types

变量的命名方式

  • lowercase for variable names
  • uppercase for symbolic constants

 

  • signed / unsigned (default, machine depends)
  • unsigned int: suffixed by U or u
  • long int: suffixed by L or l
  • octal number: starts with 0(zero)
  • hexadecimal: starts with 0x or 0X

 

limits.h / float.h

关于宏函数  #define ,可能会遇到这里所描述的一些坑。值得注意的是,宏函数事实上采用字符串替换方式,因此注意嵌入后的优先级。自身引用(含交叉引用)只能进行一次,不能递归。#后面的字符串会直接被转义。

 

 


September 29

operations, pointer, array

 

&(Ampersand)the address of (跟着
*(Asterisk)the value of ( 跟着pointer

pointer 的大小都是一样的,是基于电脑是 32-bit 还是 64-bit

不同类型的pointer可以相互赋值嘛?不能,必须force cast

 


October 3

pointers, bitwise operations

 

指针的++ 代表地址的++ 而已

do not use [] only use pointer to operate with the array!

array pass to function

  • passed by value
  • passed by reference

In C, it is pass by reference, therefore the method has direct access to all the elements 当然这里有更加简洁的方法

 

Try all these

  • malloc()
  • calloc()
  • realloc()

 

 


October 17

Oct31 3:55pm期中考试

Assignment should put comment, but for lab test, no comments.

If the question does not clarify the input, we need to check this.

 

Specification is not clear. Need to catch the errors.

 

In Assignment 1 problem 2: check

  • user may remove empty list
  • user may enter -1
  • system run out memory
  • remember to free space

 

struct keyword 特性

  • struct 不能直接赋值,只能一个一个将内容物赋值(c99好像可以了,但是以学校电脑的c98标准为准)
  • struct名 和 变量名 可以重名
  • struct 可以嵌套 struct
  • struct name 整体,应该算是一个variable type

C is passed by values

句号的优先级比星号高,注意括号

(*pp).x 等同于  pp->x

Lab test including today's lecture

written need to write command in paper

4 bytes alignment when you are declare a new structure,不适用于char *连接的字符串。

 

 


October 24

注意-> * 之类的优先级

 

pointer - linked list 常见错误

  • Overruns and underruns
  • uninitialized pointers
  • null pointer de-referencing
  • memory leaks
  • Inappropriate use of freed memory
  • Inappropriately freed memory

 

使用注意

  • alloc() 的时候注意检查返回的是不是一个有效的pointer还是null
  • pointer 变量 使用完成的时候,应该free,不应该直接创建新的pointer覆盖在上面

 

pointer 和 array char搭配的时候,会导致第一个element不能获取 (待验证)

注意,定义的不一样

  • char *p[3] 与 char *(p[3])等价,意思为 char *[5],优先array  :    a array has five char pointers
  • int (*p)[3],意思为char (*)[5],优先pointer : a pointer pointed to a char array which length is five

 

 

 


November 7

bash command

 

 

Software engineering disasters(这个会在期末考试)

  • AT&T lines go dead
  • Mariner Rocket was Destroyed
  • Hartford Coliseum Collapse

 

 

 


November 14

bash command

 

 

linux的权限

  • u - user
  • g - group
  • a - all the user world

10bit权限机制

  • d 是否为目录
  • rwx  for u
  • rwx for g
  • rwx for a

x permission to execute or in the case of a directory, search it

 

 

Go back to file access in C

File Access in C

FILE pointer in C
fopen(char * name, char *mode) 返回 FILE *

mode 的方式

  • r - read
  • w - write
  • a - append

读写函数

  • getc()
  • putc()
  • fscanf()
  • prints()

 

Go back to file access in C

File Access in C

This course focus on sh only (sh -> bash)

 

unix user variables

  • no space around
  • all values store in string

 

 

 

 


November 21

bash script

 

 

 


November 28

bash script

 

 

 


December 5

bash script/ C structure

 

set

break

continue

 

当包含在双引号的时候

  • "$@" is separate string
  • "$*" is in single string

 

 

C Structure

extern variable  的运用

 

static variable 的运用

注意与java不一样!

 

register variable 的运用

register 是更加快的内存空间

有可能数量不够用,不能够活动它的地址。

 

Initialization

external static to 0

other will be garbage

在括号中字符的转换。。。

for variable in $1/*

 

这篇博文发表在 专业笔记 目录下,标签为 , , ,
版权所有,请勿转载。如需引用,请使用链接:https://note.masterchan.me/?p=1276

您的邮箱地址不会被公开,评论使用Gravatar头像。
Your email address will not be published. This blog is using Gravatar.

正在提交评论...
正在为您准备评论控件