Sams Teach Yourself C in 21 Days
8: 9: int comp(const void *s1, const void *s2); 10: 11: int main( void ) 12: { 13: char *data[MAX], buf[80], *ptr, *key, **key1; ...
Exploring the C Function Library 555 19 57: { 58: return (strcmp(*(char **)s1, *(char **)s2)); 59: } Enter 20 words, pressing En ...
A couple of points about Listing 19.6 bear mentioning. This program makes use of an array of pointers to strings, a technique in ...
Exploring the C Function Library 557 19 your program with error handling. The functions for sorting and searching data are par- ...
Before you search an array with bsearch(), what must you do? Using bsearch(), how many comparisons would be required to find an ...
Exploring the C Function Library 559 19 5.ON YOUR OWN:Write a program that consists of a menu that performs various math functio ...
30 448201x-CH19 8/13/02 11:20 AM Page 560 ...
TYPE& RUN 6 Calculating Mortgage Payments This Type & Run is called “Mortgage,” and as the name suggests, it can calcu- ...
LISTINGT&R 6 mortgage.c. The mortgage calculator 1: /* Calculates loan/mortgage payments. */ 2: 3: #include <stdio.h> ...
Calculating Mortgage Payments 563 Pis the principal,Ris the interest rate, and Tis the term. Note that the ^symbol means “to the ...
31 448201x-T&R6 8/13/02 11:19 AM Page 564 ...
DAY 20 WEEK 3 Working with Memory Today’s lesson covers some of the more advanced aspects of managing memory within your C progr ...
of errors can result when the proper conversion isn’t applied. The following sections cover C’s automatic and explicit type conv ...
Working with Memory 567 20 the compiler would first use the operand,Xand the operand 2. Once in completes it would use the resul ...
You should be aware that when an integer type is converted to a floating-point type, the resulting floating-point value might no ...
Working with Memory 569 20 LISTING20.1 casting.c. When one integer is divided by another, any fractional part of the answer is l ...
anything. Before you can use a voidpointer, you must cast it to the proper type. Note that you don’t need to cast a pointer in o ...
Working with Memory 571 20 can’t make any assumptions about memory availability. When a memory allocation func- tion is called, ...
LISTING20.2 malloc.c. Using malloc()to determine how much memory is free 1: /* Using malloc() to determine free memory.*/ 2: 3: ...
Working with Memory 573 20 40: current->next = (struct kilo*) malloc(sizeof(struct kilo)); 41: current = current->next; 42 ...
«
25
26
27
28
29
30
31
32
33
34
»
Free download pdf