From 46f38332aabb28b94734ee7130659781c3d83a66 Mon Sep 17 00:00:00 2001 From: Marcello Lamonaca Date: Mon, 24 Mar 2025 22:25:45 +0100 Subject: [PATCH 1/2] c: refine function notes --- docs/languages/c/c.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/languages/c/c.md b/docs/languages/c/c.md index f8d7e03..3a21112 100644 --- a/docs/languages/c/c.md +++ b/docs/languages/c/c.md @@ -402,15 +402,20 @@ It is possible to declare functions **after** the main only if the *prototype* i To return multiple variables those variables can be passed by reference so that their values is adjourned in the main. ```c -type function_name(type argument1, ...); // function prototype +// function prototype (usually in a .h file) +type function_name(type argument1, ...); -type functionName (parameters) { +// function implementation (usually in a .c file) +type function_name (parameters) { return ; } -void functionName (parameters) { } +// function without a return value +void function_name (parameters) { } ``` +> **Note**: annotatic a function with `static` makes it visible only inside the file in which is implemented/declared + ### Arguments passed by reference without pointers Passing arguments by reference causes modifications made inside the function to be propagated to the values outside. @@ -421,9 +426,9 @@ type functionName (type &argument1, ...) { //code here return ; } -``` -`functionName (arguments);` +function_name (argument_1, ...); +``` ### Arguments passed by reference with pointers @@ -435,9 +440,9 @@ type function_name (type *argument_1, ...) { instructions; return ; } -``` -`function_name (&argument_1, ...);` +function_name (&argument_1, ...); +``` ## Arrays From d872337de436300faf68d657f65acdde3891206e Mon Sep 17 00:00:00 2001 From: Marcello Lamonaca Date: Mon, 24 Mar 2025 22:28:23 +0100 Subject: [PATCH 2/2] c: remove notes about vectors --- docs/languages/c/c.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/languages/c/c.md b/docs/languages/c/c.md index 3a21112..37d1793 100644 --- a/docs/languages/c/c.md +++ b/docs/languages/c/c.md @@ -316,13 +316,6 @@ string.c_str(); //reads string char by char string.find(substring); // The zero-based index of the first character in string object that matches the requested substring or characters ``` -## Vectors - -```c -#include -vector vector_name = {values}; //variable length array -``` - ## Decision Statements ### If Statements