external and static array will be initialized to zero by default. automatic array should be initialized manually. The method to initialized automatic array e.g. int a[100] = {0} (other unset elements will be set to zero).
strlen Vs sizeof
1) when applied to a pointer
strelen will renturn the number of the characters in the null-terminated string while sizeof will return the pointer size in bytes, which will probably be 4 bytes.
2) when applied to an array name
both return the size of the array.
NULL character
all bits are set to 0 and thus have a numeric value of 0, presented in the ASCII character set. null character can also be represented as '\0' in the source code.
Question: Can you input a null character in a disk file?
EOF
symbolic value (macro) EOF for end-of-file. no more data can be read from a data source. The data source is usually called a file or stream. The actual value of EOF is a system-dependent negative number, commonly -1, which is guaranteed to be unequal to any valid character code.
EOF is one of the control character or non-print character (which means itself does not represent a written symbol). in Unix, ctrl + d, in Windows, ctrl+z
getline Vs fgets Vs scanf
char * fgets (char *s, int count, FILE *stream)
The
fgets
function reads characters from the stream stream up to and including a newline character and stores them in the string s, adding a null character to mark the end of the string.http://www.gnu.org/software/libc/manual/html_mono/libc.html
No comments:
Post a Comment