diff --git a/docs/languages/c/c.md b/docs/languages/c/c.md index 37d1793..f8d7e03 100644 --- a/docs/languages/c/c.md +++ b/docs/languages/c/c.md @@ -316,6 +316,13 @@ 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 @@ -395,20 +402,15 @@ 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 -// function prototype (usually in a .h file) -type function_name(type argument1, ...); +type function_name(type argument1, ...); // function prototype -// function implementation (usually in a .c file) -type function_name (parameters) { +type functionName (parameters) { return ; } -// function without a return value -void function_name (parameters) { } +void functionName (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. @@ -419,10 +421,10 @@ type functionName (type &argument1, ...) { //code here return ; } - -function_name (argument_1, ...); ``` +`functionName (arguments);` + ### Arguments passed by reference with pointers Passing arguments by reference causes modifications made inside the function to be propagated to the values outside. @@ -433,10 +435,10 @@ type function_name (type *argument_1, ...) { instructions; return ; } - -function_name (&argument_1, ...); ``` +`function_name (&argument_1, ...);` + ## Arrays ```c