@GSMC/서용덕: DMD Programming
week 4 review
maetel
2008. 3. 27. 09:53
strcmp
Compare two strings
Returns an integral value indicating the relationship between the strings:
A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value in str1 than in str2; And a value less than zero indicates the opposite.
printf format tags
%[flags][width][.precision][length]specifier
atoi
Convert string to integer
On success, the function returns the converted integral number as an int value.
If no valid conversion could be performed, a zero value is returned.
If the correct value is out of the range of representable values, INT_MAX or INT_MIN is returned.
StudentRecord record[NStudent];
StudentRecord *record;
StudentRecord *record_c;
record = new StudentRecord[NStudent];
// C++ version of allocating a memory block
record_c = (StudentRecord *) malloc (sizeof(StudentRecord)*NStudent);
// C version of allocating a memory block
// void * malloc ( size_t size );
StudentRecord *record_c;
record = new StudentRecord[NStudent];
// C++ version of allocating a memory block
record_c = (StudentRecord *) malloc (sizeof(StudentRecord)*NStudent);
// C version of allocating a memory block
// void * malloc ( size_t size );
malloc
Allocate memory block
ref. Dynamic Memory Allocation: new and delete (C++)
"NUL indicates end-of-string." (교재 65쪽)
memcpy
서 교수님:
두 개의 struct type 데이터에 대해서, A = B;라고 하여 B를 A에 assign 하는 경우 대부분은 성립합니다. 그러나, struct 내부에서 배열을 가지고 있는 경우에는 그렇지 않습니다. 그래서 memcpy() 라는 함수를 사용하여 메모리를 블럭 단위로 카피하는 방법이 있습니다. 이는 음악 CD나 DVD 의 바이너리 카피를 만드는 것과 같은 이치입니다.