Sams Teach Yourself C in 21 Days
printf(“%d”, multi[0][0]); printf(“%d”, *multi[0]); printf(“%d”, **multi); These concepts apply equally to arrays with three or ...
Pointers: Beyond the Basics 395 4: #include <stdio.h> 15 5: 6: void printarray_1(int (*ptr)[4]); 7: void printarray_2(int ...
53: int *p, count; 54: p = (int *)ptr; 55: 56: for (count = 0; count < (4 * n); count++) 57: printf(“\n%d”, *p++); 58: } 1 2 ...
Pointers: Beyond the Basics 397 15 The second function,printarray_2(), takes a different approach. It too is passed a pointer to ...
Strings and Pointers: A Review .................................................................... This is a good time to revie ...
Pointers: Beyond the Basics 399 15 It initializes message[0]to point to the first character of the string “one”, message[1]to p ...
You probably can see how manipulating the array of pointers is easier than manipulating the strings themselves. This advantage i ...
Pointers: Beyond the Basics 401 15 Pulling Things Together With an Example .................................................. No ...
array moves it up one more position, and so on. It requires n–1 passes to move it to the first position, where it belongs. Note ...
Pointers: Beyond the Basics 403 37: char buffer[80]; /* Temporary storage for each line. */ 15 38: 39: puts(“Enter one line at t ...
apple dog merry program zoo It will be worthwhile for you to examine some of the details of this program. Several new library fu ...
Pointers: Beyond the Basics 405 15 After execution returns from get_lines()tomain(), the following has been accom- plished (assu ...
The program in Listing 15.7 is the most complex you have yet encountered in this book. It uses many of the C programming techniq ...
Pointers: Beyond the Basics 407 15 Declaring a Pointer to a Function ........................................................... ...
float square(float x); // The function prototype. float (*ptr)(float x); // The pointer declaration. float square(float x) // Th ...
Pointers: Beyond the Basics 409 15 OUTPUT 43.560000 43.560000 Precision of the values might cause some numbers to not display as ...
16: for (;;) 17: { 18: puts(“\nEnter an integer between 1 and 10, 0 to exit: “); 19: scanf(“%d”, &nbr); 20: 21: if (nbr == 0 ...
Pointers: Beyond the Basics 411 15 You entered something other than 1 or 2. Enter an integer between 1 and 10, 0 to exit: 0 This ...
29: ptr = one; 30: else if (nbr == 2) 31: ptr = two; 32: else 33: ptr = other; 34: func1(ptr); 35: } 36: return 0; 37: } 38: 39: ...
Pointers: Beyond the Basics 413 15 One programming situation in which you might use pointers to functions is one in which sortin ...
«
17
18
19
20
21
22
23
24
25
26
»
Free download pdf