Skip to content

Commit

Permalink
daily upload 12.17
Browse files Browse the repository at this point in the history
  • Loading branch information
TGSpock123 committed Dec 18, 2023
1 parent 6d898c6 commit b48ba93
Show file tree
Hide file tree
Showing 42 changed files with 179 additions and 31 deletions.
27 changes: 27 additions & 0 deletions 10_plus/10.10.c
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;
}
15 changes: 15 additions & 0 deletions 10_plus/10.11.c
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;
}
32 changes: 32 additions & 0 deletions 10_plus/10.12.c
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;
}
14 changes: 14 additions & 0 deletions 10_plus/10.13.c
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;
}
3 changes: 3 additions & 0 deletions 10_plus/10.13_14.h
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);
21 changes: 21 additions & 0 deletions 10_plus/10.14.c
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;
}
}
16 changes: 16 additions & 0 deletions 10_plus/10.9.c
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;
}
3 changes: 3 additions & 0 deletions 10_plus/10.9_10.h
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);
2 changes: 1 addition & 1 deletion 10_plus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{
"directoryIndex" : 0,
"id" : "10_plus::@6890427a1f51a3e7e1df",
"jsonFile" : "target-10_plus-Debug-ba98c6d6ec40d23a50bd.json",
"jsonFile" : "target-10_plus-Debug-fdd78151459e882e1421.json",
"name" : "10_plus",
"projectIndex" : 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"objects" :
[
{
"jsonFile" : "codemodel-v2-6f8b5d172b22e65cf7af.json",
"jsonFile" : "codemodel-v2-81e8f7e3803420ec4a42.json",
"kind" : "codemodel",
"version" :
{
Expand Down Expand Up @@ -86,7 +86,7 @@
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-6f8b5d172b22e65cf7af.json",
"jsonFile" : "codemodel-v2-81e8f7e3803420ec4a42.json",
"kind" : "codemodel",
"version" :
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "10.8.c",
"path" : "10.12.c",
"sourceGroupIndex" : 0
}
],
Expand Down
Binary file modified 10_plus/cmake-build-debug/.ninja_deps
Binary file not shown.
8 changes: 6 additions & 2 deletions 10_plus/cmake-build-debug/.ninja_log
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 modified 10_plus/cmake-build-debug/10_plus
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion 10_plus/cmake-build-debug/CMakeFiles/clion-Debug-log.txt
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
4 changes: 2 additions & 2 deletions 10_plus/cmake-build-debug/Testing/Temporary/LastTest.log
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
6 changes: 3 additions & 3 deletions 10_plus/cmake-build-debug/build.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ cmake_ninja_workdir = /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/1

build cmake_object_order_depends_target_10_plus: phony || CMakeFiles/10_plus.dir

build CMakeFiles/10_plus.dir/10.8.c.o: C_COMPILER__10_plus_unscanned_Debug /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus/10.8.c || cmake_object_order_depends_target_10_plus
DEP_FILE = CMakeFiles/10_plus.dir/10.8.c.o.d
build CMakeFiles/10_plus.dir/10.12.c.o: C_COMPILER__10_plus_unscanned_Debug /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus/10.12.c || cmake_object_order_depends_target_10_plus
DEP_FILE = CMakeFiles/10_plus.dir/10.12.c.o.d
FLAGS = -g -std=gnu11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.7 -fcolor-diagnostics
OBJECT_DIR = CMakeFiles/10_plus.dir
OBJECT_FILE_DIR = CMakeFiles/10_plus.dir
Expand All @@ -63,7 +63,7 @@ build CMakeFiles/10_plus.dir/10.8.c.o: C_COMPILER__10_plus_unscanned_Debug /User
#############################################
# Link the executable 10_plus

build 10_plus: C_EXECUTABLE_LINKER__10_plus_Debug CMakeFiles/10_plus.dir/10.8.c.o
build 10_plus: C_EXECUTABLE_LINKER__10_plus_Debug CMakeFiles/10_plus.dir/10.12.c.o
FLAGS = -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.7
OBJECT_DIR = CMakeFiles/10_plus.dir
POST_BUILD = :
Expand Down
2 changes: 1 addition & 1 deletion 9_plus/9_plus/9.30.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main (void)
printf ("Now the third one: \n");
if (scanf ("%lf", &q[M - 1]) == 1)
{
pair (q, M);
pair (&q[0], M);
printf ("%lf > %lf > %lf. \n", q[0], q[1], q[2]);
printf ("Please enter another three numbers (still q to quit): \n");
printf ("Now the first one: \n");
Expand Down
Binary file modified 9_plus/9_plus/cmake-build-debug/.ninja_deps
Binary file not shown.
2 changes: 2 additions & 0 deletions 9_plus/9_plus/cmake-build-debug/.ninja_log
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
1 345 1702564121797087815 build.ninja 89680b399b5eaefe
5 153 1702564160395573201 CMakeFiles/9_plus.dir/9.31.c.o 33ea98186e0c8a08
153 390 1702564160634652318 9_plus 4f8961afe2f42660
1 575 1702615854461385433 CMakeFiles/9_plus.dir/9.30.c.o 28e2f64a1addd6aa
575 699 1702615854586251093 9_plus 4f8961afe2f42660
Binary file modified 9_plus/9_plus/cmake-build-debug/9_plus
Binary file not shown.
Binary file modified 9_plus/9_plus/cmake-build-debug/CMakeFiles/9_plus.dir/9.30.c.o
Binary file not shown.
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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ set(CMAKE_CXX_STANDARD 14)
include_directories(9)

add_executable(C_primer
10_plus/10.7.c 10_plus/10.8.c 10_plus/10.7_8.h)
10_plus/10.13.c 10_plus/10.14.c 10_plus/10.13_14.h
)
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{
"directoryIndex" : 0,
"id" : "C_primer::@6890427a1f51a3e7e1df",
"jsonFile" : "target-C_primer-Debug-90e17ebc17efde61c9dd.json",
"jsonFile" : "target-C_primer-Debug-fe2f8957925620870bf8.json",
"name" : "C_primer",
"projectIndex" : 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"objects" :
[
{
"jsonFile" : "codemodel-v2-502bade4589e59d1ca29.json",
"jsonFile" : "codemodel-v2-06f5439d6793c55423fd.json",
"kind" : "codemodel",
"version" :
{
Expand Down Expand Up @@ -86,7 +86,7 @@
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-502bade4589e59d1ca29.json",
"jsonFile" : "codemodel-v2-06f5439d6793c55423fd.json",
"kind" : "codemodel",
"version" :
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "10_plus/10.7.c",
"path" : "10_plus/10.13.c",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "10_plus/10.8.c",
"path" : "10_plus/10.14.c",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"path" : "10_plus/10.7_8.h",
"path" : "10_plus/10.13_14.h",
"sourceGroupIndex" : 1
}
],
Expand Down
Binary file modified cmake-build-debug/.ninja_deps
Binary file not shown.
12 changes: 11 additions & 1 deletion cmake-build-debug/.ninja_log
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 modified cmake-build-debug/C_primer
Binary file not shown.
4 changes: 2 additions & 2 deletions cmake-build-debug/Testing/Temporary/LastTest.log
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
10 changes: 5 additions & 5 deletions cmake-build-debug/build.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ cmake_ninja_workdir = /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/c

build cmake_object_order_depends_target_C_primer: phony || CMakeFiles/C_primer.dir

build CMakeFiles/C_primer.dir/10_plus/10.7.c.o: C_COMPILER__C_primer_unscanned_Debug /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus/10.7.c || cmake_object_order_depends_target_C_primer
DEP_FILE = CMakeFiles/C_primer.dir/10_plus/10.7.c.o.d
build CMakeFiles/C_primer.dir/10_plus/10.13.c.o: C_COMPILER__C_primer_unscanned_Debug /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus/10.13.c || cmake_object_order_depends_target_C_primer
DEP_FILE = CMakeFiles/C_primer.dir/10_plus/10.13.c.o.d
FLAGS = -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.7 -fcolor-diagnostics
INCLUDES = -I/Users/tgspock/Documents/GitHub/learn_c_primer.github.io/9
OBJECT_DIR = CMakeFiles/C_primer.dir
OBJECT_FILE_DIR = CMakeFiles/C_primer.dir/10_plus

build CMakeFiles/C_primer.dir/10_plus/10.8.c.o: C_COMPILER__C_primer_unscanned_Debug /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus/10.8.c || cmake_object_order_depends_target_C_primer
DEP_FILE = CMakeFiles/C_primer.dir/10_plus/10.8.c.o.d
build CMakeFiles/C_primer.dir/10_plus/10.14.c.o: C_COMPILER__C_primer_unscanned_Debug /Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus/10.14.c || cmake_object_order_depends_target_C_primer
DEP_FILE = CMakeFiles/C_primer.dir/10_plus/10.14.c.o.d
FLAGS = -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.7 -fcolor-diagnostics
INCLUDES = -I/Users/tgspock/Documents/GitHub/learn_c_primer.github.io/9
OBJECT_DIR = CMakeFiles/C_primer.dir
Expand All @@ -71,7 +71,7 @@ build CMakeFiles/C_primer.dir/10_plus/10.8.c.o: C_COMPILER__C_primer_unscanned_D
#############################################
# Link the executable C_primer

build C_primer: C_EXECUTABLE_LINKER__C_primer_Debug CMakeFiles/C_primer.dir/10_plus/10.7.c.o CMakeFiles/C_primer.dir/10_plus/10.8.c.o
build C_primer: C_EXECUTABLE_LINKER__C_primer_Debug CMakeFiles/C_primer.dir/10_plus/10.13.c.o CMakeFiles/C_primer.dir/10_plus/10.14.c.o
FLAGS = -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.7
OBJECT_DIR = CMakeFiles/C_primer.dir
POST_BUILD = :
Expand Down

0 comments on commit b48ba93

Please sign in to comment.