-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d898c6
commit b48ba93
Showing
42 changed files
with
179 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdio.h> | ||
#include "10.9_10.h" | ||
int sum (int ar[], int n) | ||
{ | ||
int i; | ||
int total = 0; | ||
|
||
for (i = 0; i < n; i ++) | ||
{ | ||
total += ar[i]; | ||
} | ||
printf ("The size of ar is %zd bytes. \n", sizeof ar); | ||
|
||
return total; | ||
} | ||
int sump (int * start, int * end) | ||
{ | ||
int total = 0; | ||
|
||
while (start < end) | ||
{ | ||
total += *start; | ||
start ++; | ||
} | ||
|
||
return total; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <stdio.h> | ||
int data[2] = {100, 200}; | ||
int moredata[2] = {300, 400}; | ||
int main (void) | ||
{ | ||
int * p1, * p2, * p3; | ||
|
||
p1 = p2 = data; | ||
p3 = moredata; | ||
printf (" *p1 = %d, *p2 = %d, *p3 = %d\n", *p1, *p2, *p3); | ||
printf ("*p1 ++ = %d, *++ p2 = %d, ++ (*p3) = %d\n", *p1 ++, *++ p2, ++ (*p3)); | ||
printf (" *p1 = %d, *p2 = %d, *p3 = %d\n", *p1, *p2, *p3); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <stdio.h> | ||
|
||
int main (void) | ||
{ | ||
int urn [5] = {100, 200, 300, 400, 500}; | ||
int * ptr1, * ptr2, *ptr3; | ||
|
||
|
||
ptr1 = urn; | ||
ptr2 = &urn [2]; | ||
printf ("pointer value, dereferenced pointer, pointer address: \n"); | ||
printf ("ptr1 = %p, *ptr1 = %d, &ptr1 = %p\n", ptr1, *ptr1, &ptr1); | ||
ptr3 = ptr1 + 4; | ||
printf ("\nadding an int to a pointer: \n"); | ||
printf ("prt1 + 4 = %p, *(ptr1 + 4) = %d\n", ptr1 + 4, *(ptr1 + 4)); | ||
ptr1 ++; | ||
printf ("\nvalues after ptr1 ++:\n"); | ||
printf ("ptr1 = %p, *ptr1 = %d, &ptr1 = %p\n", ptr1, *ptr1, &ptr1); | ||
ptr2 --; | ||
printf ("\nvalues after -- ptr2:\n"); | ||
printf ("ptr2 = %p, *ptr2 = %d, &ptr2 = %p\n", ptr2, *ptr2, &ptr2); | ||
-- ptr1; | ||
++ ptr2; | ||
printf ("\nPointers reset to original values:\n"); | ||
printf ("ptr1 = %p, ptr2 = %p\n", ptr1, ptr2); | ||
printf ("\nsubtracting one pointer from another: \n"); | ||
printf ("ptr2 = %p, ptr1 = %p ptr2 - ptr1 = %td\n", ptr2, ptr1, ptr2 - ptr1); | ||
printf ("\nsubtracting an int from a pointer: \n"); | ||
printf ("ptr3 = %p, ptr3 - 2 = %p\n", ptr3, ptr3 - 2); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdio.h> | ||
#include "10.13_14.h" | ||
int main (void) | ||
{ | ||
double dip[SIZE] = {20.0, 17.66, 8.2, 15.3, 22.22}; | ||
|
||
printf ("The original dip array: \n"); | ||
show_array (dip, SIZE); | ||
mult_array (dip, SIZE, 2.5); | ||
printf ("The dip array after calling mult_array(): \n"); | ||
show_array (dip, SIZE); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#define SIZE 5 | ||
void show_array (const double ar[], int n); | ||
void mult_array (double * ar, int n, double mult); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdio.h> | ||
#include "10.13_14.h" | ||
void show_array (const double ar[], int n) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < n; i ++) | ||
{ | ||
printf ("%8.3f", ar[i]); | ||
} | ||
putchar ('\n'); | ||
} | ||
void mult_array (double ar[], int n, double mult) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < n; i ++) | ||
{ | ||
ar[i] *= mult; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <stdio.h> | ||
#include "10.9_10.h" | ||
int main (void) | ||
{ | ||
int marbles[SIZE] = {20, 10, 5, 39, 4, 16, 19, 26, 31, 20}; | ||
long answer; | ||
|
||
answer = sum (marbles, SIZE); | ||
printf ("The total number of marbles is %ld. \n", answer); | ||
printf ("The size of marbles is %zd bytes with %zd element. \n", sizeof marbles, | ||
sizeof marbles / sizeof marbles[0]); | ||
printf ("The total number of marbles is %d, in another method. \n", sump (marbles, marbles + SIZE)); | ||
|
||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#define SIZE 10 | ||
int sum (int ar[], int n); | ||
int sump (int * start, int * end); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ project(10_plus C) | |
|
||
set(CMAKE_C_STANDARD 11) | ||
|
||
add_executable(10_plus 10.8.c ) | ||
add_executable(10_plus 10.12.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# ninja log v5 | ||
1 109 1702553285008837028 CMakeFiles/10_plus.dir/10.6.c.o 5a331c68b6c38d00 | ||
622 837 1702614375084499001 10_plus 61bafc99badd150b | ||
1 94 1702617702147214875 CMakeFiles/10_plus.dir/10.10.c.o 440426100649bdfa | ||
1 106 1702618741316400631 CMakeFiles/10_plus.dir/10.11.c.o 8e75bce6881361f1 | ||
1 622 1702614374868595042 CMakeFiles/10_plus.dir/10.7.c.o 1e18d949d1aef50d | ||
107 284 1702618741489331650 10_plus 80808cea9c55f17c | ||
0 93 1702617702146103915 CMakeFiles/10_plus.dir/10.9.c.o 7e601dff9ca5f896 | ||
1 228 1702615135836040224 CMakeFiles/10_plus.dir/10.8.c.o 7e3301fb757e0e25 | ||
3 207 1702615152861270317 10_plus a059e66eb2ad5f05 | ||
0 199 1702620425452530568 CMakeFiles/10_plus.dir/10.12.c.o 882194e809a577c7 | ||
200 415 1702620425668211985 10_plus a1fb0accaa872bfa |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/Applications/CLion.app/Contents/bin/cmake/mac/x64/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/x64/ninja -G Ninja -S /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus -B /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus/cmake-build-debug | ||
-- Configuring done (0.0s) | ||
-- Configuring done (0.1s) | ||
-- Generating done (0.0s) | ||
-- Build files have been written to: /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus/cmake-build-debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Start testing: Dec 15 12:39 CST | ||
Start testing: Dec 15 14:07 CST | ||
---------------------------------------------------------- | ||
End testing: Dec 15 12:39 CST | ||
End testing: Dec 15 14:07 CST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
9_plus/9_plus/cmake-build-debug/CMakeFiles/9_plus.dir/9.30.c.o
Binary file not shown.
4 changes: 2 additions & 2 deletions
4
9_plus/9_plus/cmake-build-debug/Testing/Temporary/LastTest.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Start testing: Dec 14 22:29 CST | ||
Start testing: Dec 15 12:50 CST | ||
---------------------------------------------------------- | ||
End testing: Dec 14 22:29 CST | ||
End testing: Dec 15 12:50 CST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
# ninja log v5 | ||
92 223 1701831957193443616 C_primer 42509e55b60c2aac | ||
335 503 1702822896535710815 C_primer 5cb5d6dfc54446d4 | ||
4 335 1702822896367170007 CMakeFiles/C_primer.dir/9_plus/9_plus/9.36.c.o 9f95dd8b31879556 | ||
0 267 1702717481449984888 CMakeFiles/C_primer.dir/10_plus/10.12.c.o d0b2887c66daa4b1 | ||
0 305 1702822896335875576 CMakeFiles/C_primer.dir/9_plus/9_plus/9.35.c.o c09ce47479a5514a | ||
1 823 1702825261308715094 CMakeFiles/C_primer.dir/10_plus/10.13.c.o 7bef308e0e43b8ac | ||
3 825 1702825261305992604 CMakeFiles/C_primer.dir/10_plus/10.14.c.o 27c11ea85739635 | ||
826 962 1702825261443792962 C_primer a3cbc96ef3d4c1f7 | ||
0 110 1702825272983423224 CMakeFiles/C_primer.dir/10_plus/10.13.c.o 7bef308e0e43b8ac | ||
1 138 1702825381555261318 CMakeFiles/C_primer.dir/10_plus/10.13.c.o 7bef308e0e43b8ac | ||
1 144 1702825381558358062 CMakeFiles/C_primer.dir/10_plus/10.14.c.o 27c11ea85739635 | ||
144 322 1702825381740197165 C_primer a3cbc96ef3d4c1f7 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Start testing: Dec 14 22:50 CST | ||
Start testing: Dec 17 23:03 CST | ||
---------------------------------------------------------- | ||
End testing: Dec 14 22:50 CST | ||
End testing: Dec 17 23:03 CST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters