{ "id": "jhhrNu9S7EWJnRqF", "createdBy": "89808a9dlHhsBb", "dateCreated": 1713192447954, "name": "Lab-Linux: C-Programming", "meta": { "logo": "https://raw.githubusercontent.com/edrys-labs/lab-linux/main/media/c.jpg", "description": "Explore the basics of C programming and GCC compiler usage with our step-by-step tutorial designed for beginners. Start by creating a simple \"Hello, World!\" program, then enhance it to interact with users by asking for their name and providing a personalized greeting. Additionally, learn how to identify and fix a common coding error through a detailed explanation of GCC error messages. This tutorial provides a practical introduction to writing, compiling, and debugging simple C programs, perfect for young learners and newcomers to programming.", "selfAssign": true, "defaultNumberOfRooms": 0 }, "members": { "teacher": [], "student": [] }, "modules": [ { "url": "https://raw.githubusercontent.com/edrys-labs/module-markdown-it/2.0.0/index.html", "config": "# Welcome to Lab-Linux: C-Programming\n\nC is a powerful computer programming language that lets you tell a computer what to do.\nIt's a bit like writing a recipe that the computer follows to complete tasks.\nPeople use C to create software applications, help gadgets like your microwave work, or even make video games!\n\nHere’s why C is cool for learning:\n\n1. **Simple to start**:\n Even though it's powerful, C isn't very complicated to learn.\n It has a small number of commands to remember, which are like the basic building blocks for more complex programs.\n\n2. **Everywhere in technology**:\n Many of the electronics around us, like robots and smartphones, use C to function.\n Learning C can help you understand more about how these things work.\n\n3. **A great foundation**:\n Once you understand C, learning other languages like Python, Java, or C++ becomes easier because many programming languages are based on C.\n\nImagine C as the language that bridges your instructions with the computer’s actions.\nBy learning C, you're learning how to speak directly to computers, and that’s a super useful skill to have!\n\n__Visit a station by clicking onto it and then explore the terminal ;-)__", "studentConfig": "", "teacherConfig": "## Welcome for Teachers\n\n> This can be used as a base laboratory to create further and more elaborate labs with [edrys-Lite](https://edrys-labs.github.io).\n> You are currently in the Lobby. If there is a station available you can switch to it and try out the terminal.\n> Otherwise, if you are in teacher-mode you can share a lab by clicking onto `setting` >> `station` and then by clicking the presented link,\n> which is the same as the current link, but only with the word `station` instead of `classroom`.", "stationConfig": "", "showInCustom": "lobby", "width": "full", "height": "huge" }, { "url": "https://edrys-labs.github.io/module-editor/index.html", "config": { "editorText": "Starting text in editor...", "runCommand": "execute", "language": "cpp", "theme": "light" }, "studentConfig": "", "teacherConfig": "", "stationConfig": "", "showInCustom": "station", "width": "full", "height": "medium" }, { "url": "https://raw.githubusercontent.com/edrys-labs/module-markdown-it/2.0.0/index.html", "config": "# Welcome to the Station\n\n## C-Programming Tutorial\n\nCopy the following program into the editor\n\n```cpp\n#include <stdio.h>\n\nint main() {\n printf(\"Hello, world!\");\n return 0;\n}\n```\n\n... and execute it ...\n\n### Handling inputs\n\nModify the program to look like this:\n\n``` c\n#include <stdio.h>\n\nint main() {\n // This array stores the name\n char name[50];\n \n printf(\"Enter your name: \");\n // Read user input into the 'name' variable\n scanf(\"%s\", name); \n printf(\"Hello, %s!\\n\", name);\n\n return 0;\n}\n```\n\nCompile and Run Your Modified Program...\n\nFollow the prompt to enter your name, and you should see a personalized greeting.\n\n### Introduce an Error\n\nNow, let's introduce a common error. Suppose we accidentally misspell the `printf` function.\n\n1. **Modify your program** again:\n\n ```c\n #include <stdio.h>\n\n int main() {\n char name[50];\n\n printf(\"Enter your name: \");\n scanf(\"%s\", name)\n // Error: 'print' is used instead of 'printf'\n print(\"Hello, %s!\\n\", name);\n\n return 0;\n }\n ```\n\n2. Try to compile it again with.\n\n### Identifying and Fixing the Error\n\nWhen you try to compile this incorrect program, GCC will generate an error message. Here's what you might see in your terminal:\n\n``` bash\nmain.c:7:21: error: expected ‘;’ before ‘print’\n 7 | scanf(\"%s\", name)\n | ^\n | ;\n 8 | // Error: 'print' is used instead of 'printf'\n 9 | print(\"Hello, %s!\\n\", name);\n | ~~~~~ \n```\n\n**What went wrong?**\n\n- **Implicit declaration of function ‘print’**: This means GCC doesn't recognize `print` as a valid function. This is because there is no standard function called `print` in C; it should be `printf`.\n- **Expected ‘;’ before ‘(’ token**: This error appears because GCC is confused by the unexpected function name and mishandles the syntax of C.\n\n**How to fix it:**\n\n- Replace `print` with `printf`.\n- Make sure every function call ends with a semicolon (`;`).\n\nAfter correcting the error, save your file and compile it again. When you run it, it should work as expected, asking for your name and greeting you correctly.\n\nThis process of identifying errors from compiler messages and resolving them is crucial in learning to program in C or any programming language.\n ", "studentConfig": "", "teacherConfig": "", "stationConfig": "## Instructions for Station-Sharing \n\nYou are currently responsible for sharing a station of this lab.\nYou have multiple options to share a or your terminal.\nTherefor we use the pyxtermjs - terminal server from:\n\nhttps://github.com/edrys-labs/module-pyxtermjs\n\n### Using Docker\n\nIf you haven't done it so far, install [docker](https://docs.docker.com/engine/install/).\nOr, follow one of the instruction-videos for your system:\n\n<details>\n<summary>Install Docker on Linux</summary> \n<iframe\n style=\"width: 100%; aspect-ratio: 16 / 9\"\n src=\"https://www.youtube.com/embed/cqbh-RneBlk?si=juvUM5d2OSZ28WBv\"\n title=\"YouTube video player\"\n frameborder=\"0\"\n allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\"\n referrerpolicy=\"strict-origin-when-cross-origin\"\n allowfullscreen></iframe>\n</details>\n\n<details>\n<summary>Install Docker on Windows</summary>\n<iframe\n style=\"width: 100%; aspect-ratio: 16 / 9\"\n src=\"https://www.youtube.com/embed/WDEdRmTCSs8?si=X0agStn1akNcZLGu\"\n title=\"YouTube video player\"\n frameborder=\"0\"\n allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\"\n referrerpolicy=\"strict-origin-when-cross-origin\"\n allowfullscreen></iframe>\n</details>\n\n<details>\n<summary>Install Docker on MacOS</summary>\n<iframe\n style=\"width: 100%; aspect-ratio: 16 / 9\"\n src=\"https://www.youtube.com/embed/-EXlfSsP49A?si=OZ_l4_2hDKb6ULQ_\"\n title=\"YouTube video player\"\n frameborder=\"0\"\n allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\"\n referrerpolicy=\"strict-origin-when-cross-origin\"\n allowfullscreen></iframe>\n</details>\n\nThen the only thing that is required is to run the following command:\n\n```bash\ndocker run -it -p 5000:5000 crosslab/edrys_pyxtermjs_development:latest\n```\n\nThis will download the pyxtermjs terminal-server from docker-hub and run it in a secure environment.\nIt contains support for:\n\n- `clojure`\n- `g++`\n- `gcc`\n- `golang`\n- `haskell`\n- `java`\n- `lua`\n- `mono`\n- `nodejs`\n- `python 3`\n- `r`\n- `rustc`\n\n### Using Python\n\nYou can also share your terminal directly via Python, visit the follwing project\n\nhttps://github.com/edrys-labs/module-pyxtermjs\n\n... the easiest way is to perform the following steps:\n\n``` bash\n# 1. clone the repository or download the folder manually\ngit clone https://github.com/edrys-labs/module-pyxtermjs\n\n# 2. install all required sources\npip3 install -r requirements.txt\n\n# 3. run the terminal-server\npython3 -m pyxtermjs --cors True --command bash --port 5000\n```", "showInCustom": "station", "width": "half", "height": "huge" }, { "url": "https://edrys-labs.github.io/module-pyxtermjs/index.html", "config": "", "studentConfig": "", "teacherConfig": "", "stationConfig": { "server": "http://localhost:5000/pty", "execute": "execute", "script": "echo $CODE | base64 --decode > main.c\ngcc main.c & ./a.out", "enable": { "teacher": true, "student": true } }, "showInCustom": "station", "width": "full", "height": "medium" } ] }