Sams Teach Yourself C in 21 Days
4.BUG BUSTER:Is anything wrong with the following? char *string1, string2; string1 = “Hello World”; strcpy( string2, string1); p ...
DAY 18 WEEK 3 Getting More from Functions As you know by now, functions are central to C programming. Today you will learn more ...
The argument expression is evaluated. The result is copied onto the stack,a temporary storage area in memory. The function retr ...
Getting More from Functions 517 18 consideration, passing an argument by reference instead of by value offers an advantage as we ...
The function used in Figure 18.2 is not a good example of a real program in which you would use passing by reference, but it doe ...
Getting More from Functions 519 18 34: { 35: *a = 0; 36: *b = 0; 37: *c = 0; 38: } Before calling by_value(), x = 2, y = 4, z = ...
TypevoidPointers .............................................................................................. You’ve seen the ...
Getting More from Functions 521 18 Typecasts are covered in more detail on Day 20, “Working with Memory.” Getting back to the or ...
32: printf(“\n%ld”, l); 33: printf(“\n%f”, f); 34: printf(“\n%lf\n”, d); 35: return 0; 36: } 37: 38: void half(void *pval, char ...
Getting More from Functions 523 18 As implemented in this listing, the function half()on lines 38–66 includes no error checking ...
specifiers in the format string tells the function how many additional arguments to expect. More directly, one of the function’s ...
Getting More from Functions 525 18 Now for that example: The function average()in Listing 18.3 calculates the arithmetic average ...
The first average is 5.500000. The second average is 87.800000. The function average()is first called on line 19. The first argu ...
Getting More from Functions 527 18 Now that you have the declaration format straight, how do you use a function that returns a p ...
Enter two integer values: 1111 3000 The larger value is 3000. The larger value is 3000. This is a relatively easy program to fol ...
Getting More from Functions 529 18 pointer that can point to any type of C data object. Type voidpointers are most com- monly us ...
What is one reason you would use a voidpointer? When using a voidpointer, what is meant by a typecast, and when must you use it ...
Getting More from Functions 531 18 Write a function that (a) is passed an array of any numeric data type as an argu- ment, (b) ...
29 448201x-CH18 8/13/02 11:14 AM Page 532 ...
DAY 19 WEEK 3 Exploring the C Function Library As you’ve seen throughout this book, much of C’s power comes from the func- tions ...
«
23
24
25
26
27
28
29
30
31
32
»
Free download pdf