{"id":20345766,"url":"https://github.com/izzypt/cpp-module-00","last_synced_at":"2026-05-08T11:38:30.496Z","repository":{"id":177913095,"uuid":"661078234","full_name":"izzypt/CPP-Module-00","owner":"izzypt","description":"Namespaces, classes, member functions, stdio streams, initialization lists, static, const, and some other basic stuf","archived":false,"fork":false,"pushed_at":"2023-07-04T12:49:18.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T21:45:38.627Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/izzypt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-01T18:07:51.000Z","updated_at":"2023-07-01T19:02:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"d5695bf8-f7a5-4575-acab-2e6f2cfb4f00","html_url":"https://github.com/izzypt/CPP-Module-00","commit_stats":null,"previous_names":["izzypt/cpp-module-00"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2FCPP-Module-00","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2FCPP-Module-00/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2FCPP-Module-00/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2FCPP-Module-00/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/izzypt","download_url":"https://codeload.github.com/izzypt/CPP-Module-00/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241876606,"owners_count":20035396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T22:09:42.316Z","updated_at":"2026-05-08T11:38:25.431Z","avatar_url":"https://github.com/izzypt.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CPP-Module-00\nNamespaces, classes, member functions, stdio streams, initialization lists, static, const, and some other basic stuff.\n\n- https://cplusplus.com/reference/string/string/\n- https://cplusplus.com/reference/iomanip/\n\n# General rules\n\n### Compiling\n\n - Compile your code with c++ and the flags -Wall -Wextra -Werror\n - Your code should still compile if you add the flag -std=c++98\n\n### Formatting and naming conventions\n\n - The exercise directories will be named this way: ex00, ex01, ... , exn\n - Write class names in UpperCamelCase format. Files containing class code will always be named according to the class name. For instance:\n  ClassName.hpp/ClassName.h, ClassName.cpp, or ClassName.tpp. Then, if you\n  have a header file containing the definition of a class \"BrickWall\" standing for a\n  brick wall, its name will be BrickWall.hpp.\n - Unless specified otherwise, every output messages must be ended by a new-line\ncharacter and displayed to the standard output.\n- Goodbye Norminette! No coding style is enforced in the C++ modules. You can\nfollow your favorite one.\n\n### Allowed/Forbidden\n\nYou are not coding in C anymore. Time to C++! Therefore:\n- You are allowed to use almost everything from the standard library. Thus, instead\nof sticking to what you already know, it would be smart to use as much as possible\nthe C++-ish versions of the C functions you are used to.\n- However, you can’t use any other external library. It means C++11 (and derived\nforms) and Boost libraries are forbidden. The following functions are forbidden\ntoo: *printf(), *alloc() and free(). If you use them, your grade will be 0 and\nthat’s it.\n- Note that unless explicitly stated otherwise, the using namespace \u003cns_name\u003e and\nfriend keywords are forbidden. Otherwise, your grade will be -42.\n- You are allowed to use the STL in Module 08 only. That means: no\nContainers (vector/list/map/and so forth) and no Algorithms (anything that\nrequires to include the \u003calgorithm\u003e header) until then. Otherwise, your grade will\nbe -42.\n\n### A few design requirements\n- Memory leakage occurs in C++ too. When you allocate memory (by using the new\nkeyword), you must avoid memory leaks.\n- From Module 02 to Module 08, your classes must be designed in the Orthodox\nCanonical Form, except when explicitely stated otherwise.\n- Any function implementation put in a header file (except for function templates)\nmeans 0 to the exercise.\n- You should be able to use each of your headers independently from others. Thus,\nthey must include all the dependencies they need. However, you must avoid the\nproblem of double inclusion by adding include guards. Otherwise, your grade will\nbe 0.\n\n# Usefull String Methods\n\n Here's a short list of some important methods for working with strings in C++ along with a brief description of each:\n\n- ```length()``` or ```size()```:\n  - Returns the length of the string, i.e., the number of characters in the string.\n\n- ```empty()```:\n  - Checks if the string is empty or not. Returns true if the string is empty, and false otherwise.\n\n- ```clear()```:\n  - Clears the contents of the string, making it an empty string.\n\n- ```substr(start, length)```:\n  - Returns a substring of the string starting from the start index and of the specified length. If length is not provided, it returns the substring from start until the end of the string.\n\n- ```find(substring)```:\n  - Searches for the first occurrence of the substring within the string and returns its index. If the substring is not found, it returns std::string::npos.\n\n- ```replace(start, length, new_string)```:\n  - Replaces a portion of the string, specified by start and length, with the new_string.\n\n- ```append(str)```:\n  - Appends the str at the end of the string.\n\n- ```insert(pos, str)```:\n  - Inserts the str at the specified pos index within the string.\n\n- ```erase(start, length)```:\n  - Removes a portion of the string, starting from start and of the specified length.\n\n- ```compare(str)```:\n  - Compares the string with str and returns an integer value indicating their lexicographical relationship. It returns 0 if both strings are equal, a negative value if the string is less than str, and a positive value if the string is greater than str.\n\nThese are just a few commonly used methods for string manipulation in C++. There are many more methods available in the \u003cstring\u003e library that provide additional functionality, such as case conversion, character manipulation, and more.\n\n# Exercise 00\n\n![image](https://github.com/izzypt/CPP-Module-00/assets/73948790/b67bd00a-9ba0-4965-9551-4ac58803a9ef)\n\n### Usefull here :\n\nThe `toupper()` function in C++ is not part of the `\u003ciostream\u003e` or `\u003ccstring\u003e` libraries, but they indirectly include the necessary headers. \nIt is actually part of the `\u003ccctype\u003e` library, which provides functions for character handling and classification.\n\nHere's a description of the `toupper()` function:\n\n- `toupper()` is a function that is used to convert a lowercase character to its corresponding uppercase representation.\n- It takes a single argument of type `int` or `char`, which represents the character to be converted.\n- If the input character is a lowercase letter, `toupper()` returns the uppercase version of that letter.\n- If the input character is already an uppercase letter or not a letter at all, `toupper()` returns the character unchanged.\n- The function is typically used in conjunction with the standard C++ string functions, such as `std::toupper(c)` to convert a single character or `std::transform()` to convert a whole string to uppercase.\n- Here's an example usage of `toupper()`:\n```cpp\n#include \u003ccctype\u003e\n#include \u003ciostream\u003e\n\nint main() {\n    char lowercase = 'a';\n    char uppercase = std::toupper(lowercase);\n    std::cout \u003c\u003c \"Uppercase: \" \u003c\u003c uppercase \u003c\u003c std::endl;\n    return 0;\n}\n```\nOutput: \"Uppercase: A\"\n\nNote that `toupper()` operates on single characters and does not modify strings in place. If you want to convert a whole string to uppercase, you'll need to iterate over the characters and apply `toupper()` to each one.\n\n\n# Exercise 01\n\n![image](https://github.com/izzypt/CPP-Module-00/assets/73948790/fafad39c-9f9c-4ab5-af3a-3baa672288d6)\n\n![image](https://github.com/izzypt/CPP-Module-00/assets/73948790/b0ade502-4251-474d-8c21-29447cb01503)\n\nUsed and usefull function on the exercise :\n\n\n- ```std::cout```\n\n  - It is used for outputting data to the standard output stream, typically the console or terminal.\n  - You can use the \u003c\u003c operator with std::cout to send data to the output stream.\n\nFor example: \n\n```\nstd::cout \u003c\u003c \"Hello, world!\";\n\nwill print \"Hello, world!\" to the console.\n```\n\n\n- ```std::cin```\n\n  - It is used for reading input from the standard input stream, typically the keyboard.\n  - You can use the \u003e\u003e operator with std::cin to read data from the input stream into variables.\n\nFor example: \n\n```\nint num;\n\nstd::cin \u003e\u003e num;\n\nwill wait for user input and store the entered value into the variable num.\n```\n\n- ```std::setw```\n\nstd::setw is a function in the \u003ciomanip\u003e header of the C++ standard library.\nIt is used to set the width of the output field for the next value printed to the output stream.\nIt takes an integer argument that specifies the width in characters.\n\nFor example: \n\n```\nstd::cout \u003c\u003c std::setw(5) \u003c\u003c 42;\n\nwill output \" 42\" (with three leading spaces) because the width is set to 5.\n```\n\n\n- ```str.compare```\n\n  - str.compare is a member function of the std::string class in the C++ standard library.\n  - It is used to compare two strings lexicographically.\n  - It returns an integer value indicating the result of the comparison: 0 if the strings are equal, a negative value if the calling string is lexicographically less than the argument, and a positive value if the calling string is lexicographically greater.\n\nFor example: \n\n```\nstd::string str1 = \"apple\";\nstd::string str2 = \"banana\";\nint result = str1.compare(str2);\n\nwill set result to a negative value (-1) because \"apple\" is lexicographically less than \"banana\".\n```\n\n- ```std::cin.clear```\n\n  - std::cin.clear is a member function of the std::istream class in the C++ standard library.\n  - It is used to clear the error state flags of the input stream.\n  - When there is an error, such as an incorrect data type entered, the error flag is set, and subsequent input operations may fail.\n  - Calling std::cin.clear() clears the error flags, allowing you to recover from the error state and continue reading input.\n\nFor example:\n\n```\nstd::cin.clear();\n\nis commonly used in error-handling scenarios to reset the stream after an input failure.\n```\n- ```std::stoi()```\n\n  - In C++, the function `std::stoi()` (string to int) is typically used to convert a string to an integer. \n  - It is part of the `\u003cstring\u003e` header and provides more robust error handling compared to `atoi()`. Here's an example of how you can use `std::stoi()` in your code:\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n\nint main() {\n    std::string input = \"123\";\n    int number = std::stoi(input);\n    std::cout \u003c\u003c \"Number: \" \u003c\u003c number \u003c\u003c std::endl;\n    return 0;\n}\n```\n\n  Output: \"Number: 123\"\n\n\n- `std::getline()`\n\n  - The `std::getline()` allows you to read a line of input from an input stream, such as `std::cin`, and store it in a string variable.\n  - Function Signature: `std::getline(std::istream\u0026 input_stream, std::string\u0026 input_string, char delimiter = '\\n')`\n  - Header: `\u003cstring\u003e`\n  - Parameters:\n    - `input_stream`: The input stream from which the line is to be read. Commonly used with `std::cin`.\n    - `input_string`: The string variable in which the line of input is stored.\n    - `delimiter` (optional): The delimiter character used to determine the end of the line. By default, it is set to the newline character (`\\n`).\n  - `std::getline()` reads characters from the input stream until it encounters the specified delimiter or reaches the end of the stream.\n  - The delimiter character is not included in the resulting string.\n  - The extracted line of input is stored in the provided string variable (`input_string`).\n  - If the extraction fails or reaches the end of the stream before finding the delimiter, the function sets the failbit of the input stream, which can be checked using the stream's `good()` or `fail()` member functions.\n  - By default, `std::getline()` reads until it encounters a newline character (`\\n`), effectively reading a full line of text. However, you can specify a different delimiter if needed.\n\nExample usage:\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n\nint main() {\n    std::string input;\n\n    std::cout \u003c\u003c \"Enter your name: \";\n    std::getline(std::cin, input);  // Read a line of input from std::cin and store it in 'input'\n\n    std::cout \u003c\u003c \"Hello, \" \u003c\u003c input \u003c\u003c \"!\" \u003c\u003c std::endl;\n\n    return 0;\n}\n```\n\nIn this example, `std::getline(std::cin, input)` reads a line of input from the user, storing it in the `input` string variable. The program then greets the user by printing their name back to the console.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizzypt%2Fcpp-module-00","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fizzypt%2Fcpp-module-00","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizzypt%2Fcpp-module-00/lists"}