From 8fcde6dd14ebc360bd76b94a889bdbebda5b8fd2 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 9 Apr 2023 13:52:04 +0300 Subject: Update content for md --- gemfeed/2016-11-20-object-oriented-programming-with-ansi-c.md | 10 +++++----- index.md | 2 +- uptime-stats.md | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gemfeed/2016-11-20-object-oriented-programming-with-ansi-c.md b/gemfeed/2016-11-20-object-oriented-programming-with-ansi-c.md index 73297799..904631bd 100644 --- a/gemfeed/2016-11-20-object-oriented-programming-with-ansi-c.md +++ b/gemfeed/2016-11-20-object-oriented-programming-with-ansi-c.md @@ -17,7 +17,7 @@ You can do a little of object-oriented programming in the C Programming Language Let's have a look at the following sample program. All you have to do is to add a function pointer such as "calculate" to the definition of struct "something_s". Later, during the struct initialization, assign a function address to that function pointer: -``` +```c #include typedef struct { @@ -53,21 +53,21 @@ int main(void) { As you can see, you can call the function (pointed by the function pointer) with the same syntax as in C++ or Java: -``` +```c printf("%s(%f, %f) => %f\n", mult.name, a, b, mult.calculate(a,b)); printf("%s(%f, %f) => %f\n", div.name, a, b, div.calculate(a,b)); ``` However, that's just syntactic sugar for: -``` +```c printf("%s(%f, %f) => %f\n", mult.name, a, b, (*mult.calculate)(a,b)); printf("%s(%f, %f) => %f\n", div.name, a, b, (*div.calculate)(a,b)); ``` Output: -``` +```sh pbuetow ~/git/blog/source [38268]% gcc oop-c-example.c -o oop-c-example pbuetow ~/git/blog/source [38269]% ./oop-c-example Multiplication(3.000000, 2.000000) => 6.000000 @@ -80,7 +80,7 @@ Not complicated at all, but nice to know and helps to make the code easier to re However, that's not really how it works in object-oriented languages such as Java and C++. The method call in this example is not a method call as "mult" and "div" in this example are not "message receivers". I mean that the functions can not access the state of the "mult" and "div" struct objects. In C, you would need to do something like this instead if you wanted to access the state of "mult" from within the calculate function, you would have to pass it as an argument: -``` +```c mult.calculate(mult,a,b)); ``` diff --git a/index.md b/index.md index 92529ad4..a9662aa8 100644 --- a/index.md +++ b/index.md @@ -1,6 +1,6 @@ # foo.zone -> This site was generated at 2023-04-09T13:49:17+03:00 by `Gemtexter` +> This site was generated at 2023-04-09T13:51:48+03:00 by `Gemtexter` ``` |\---/| diff --git a/uptime-stats.md b/uptime-stats.md index 2572e831..a16cb668 100644 --- a/uptime-stats.md +++ b/uptime-stats.md @@ -1,6 +1,6 @@ # My machine uptime stats -> This site was last updated at 2023-04-09T13:49:17+03:00 +> This site was last updated at 2023-04-09T13:51:48+03:00 The following stats were collected via `uptimed` on all of my personal computers over many years and the output was generated by `guprecords`, the global uptime records stats analyser of mine. -- cgit v1.2.3