c-string
https://www.tutorialspoint.com/cprogramming/c_strings.htm
functions for c string:
1 | // copy string s2 into s1 |
c-array
size of array
1 | int prices[5] = { 1, 2, 3, 4, 5 }; |
c-pointer
check if pointer is not null
1 | if(ptr) /* succeeds if p is not null */ |
Operators for pointer
https://www.codingeek.com/tutorials/c-programming/operations-on-pointers-c-programming-language/
dangling pointer
A pointer initially holding valid address, but later the held address is released or freed. Then such a pointer is called as dangling pointer.
https://zh.wikipedia.org/wiki/%E8%BF%B7%E9%80%94%E6%8C%87%E9%92%88
c-diff between pointer, array, string
diff between array and pointer
https://stackoverflow.com/questions/30647709/differences-between-arrays-pointers-and-strings-in-c
https://stackoverflow.com/questions/1641957/is-an-array-name-a-pointer
https://blog.csdn.net/Hackbuteer1/article/details/6706562
array names in a C program are (in most cases) converted to pointers. One exception is when we use the sizeof
operator on an array. If a
was converted to a pointer in this context, sizeof a
would give the size of a pointer and not of the actual array, which would be rather useless, so in that case a
means the array itself.
1 |
|
1 | Size of names = 18 |
diff between char *str and char* str[]
char *str = “abcd” 先在静态区为”hello”常量分配5Byte,接着在栈里为指针str分配4Byte(32位机器)并指向”abcd”字串的首地址,因此此时str是指向第一个字符‘a’的一个指针。
char str[ ] = “abcd” 在栈里分配连续的5Byte,内容为’a’,’b’,’c’,’d’,’\0’ 此时str是数组名,同时也可转化为指向数组第一个字符‘a’的指针常量。
————————————————
版权声明:本文为CSDN博主「CHENG Jian」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/gatieme/article/details/48716093
c-structure
structure declaration
1 | struct tag_name { |
1 | typedef struct tag_name { |
c-enum
https://www.geeksforgeeks.org/enumeration-enum-c/
c-bitfield
1 | struct { |
c-input and output
standard input and output
https://www.tutorialspoint.com/cprogramming/c_input_output.htm
character: getchar, putchar
string: get, put, scanf, prinf
File I/O
https://www.tutorialspoint.com/cprogramming/c_file_io.htm
1 | FILE *fopen( const char * filename, const char * mode ); |
diff between prinft, springf and fprintf
https://www.geeksforgeeks.org/difference-printf-sprintf-fprintf/
c-preprocessors
https://www.tutorialspoint.com/cprogramming/c_preprocessors.htm
c-header
https://www.tutorialspoint.com/cprogramming/c_header_files.htm
c-type casting
https://www.tutorialspoint.com/cprogramming/c_type_casting.htm
c-error handling
https://www.tutorialspoint.com/cprogramming/c_error_handling.htm
how to use stderr
https://www.delftstack.com/zh/howto/c/c-print-to-stderr/
c-memory management
https://www.tutorialspoint.com/cprogramming/c_memory_management.htm
undefined behavior
should I cast result of malloc in C?
https://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc
stack and heap
https://blog.csdn.net/mybelief321/article/details/8912736
c-command line arguments
https://www.tutorialspoint.com/cprogramming/c_command_line_arguments.htm
c-predefined standard micros
https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html