From cf50c3f366289ebd93ac76de3aa106be12bf6f9f Mon Sep 17 00:00:00 2001 From: aditya singh rawat <80266913+unreal0901@users.noreply.github.com> Date: Sat, 18 Feb 2023 10:45:04 -0800 Subject: [PATCH 1/3] Update c.md Little typo in ouput. --- source/_posts/c.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_posts/c.md b/source/_posts/c.md index 0910149..e1c1abc 100644 --- a/source/_posts/c.md +++ b/source/_posts/c.md @@ -38,7 +38,7 @@ Run the compiled binary `hello` $ ./hello ``` -Output => Hello World +Output => Hello World! From 26f4f6b02bd13fc657d32ae21268b25441b40125 Mon Sep 17 00:00:00 2001 From: aditya singh rawat <80266913+unreal0901@users.noreply.github.com> Date: Sat, 18 Feb 2023 11:12:46 -0800 Subject: [PATCH 2/3] Added String literals Added a another way to make string that is using character pointer, modifying string literal show undefined behavior. --- source/_posts/c.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/_posts/c.md b/source/_posts/c.md index 0910149..15ed16a 100644 --- a/source/_posts/c.md +++ b/source/_posts/c.md @@ -185,6 +185,14 @@ printf("%s", greetings); // print "Hell!" ``` +Creating String using character pointer (String Literals) +```c +char *greetings = "Hello"; +printf("%s", greetings); +// print "Hello!" +``` +**NOTE**: String literals might be stored in read-only section of memory. Modifying a string literal invokes undefined behavior. You can't modify it.! + `C` **does not** have a String type, use `char` type and create an `array` of characters From 141c5a06ad6476f662d8fc74eb89917a3ceeaeb3 Mon Sep 17 00:00:00 2001 From: aditya singh rawat <80266913+unreal0901@users.noreply.github.com> Date: Sat, 18 Feb 2023 23:30:31 -0800 Subject: [PATCH 3/3] git restore and git restore --staged commands added git restore commands --- source/_posts/git.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/_posts/git.md b/source/_posts/git.md index 147fd04..7860da7 100644 --- a/source/_posts/git.md +++ b/source/_posts/git.md @@ -59,6 +59,14 @@ Commit all your tracked files to versioned history ``` shell script $ git commit -am "commit message" ``` +Discard changes in working directory which is not staged +``` shell script +$ git restore [file] +``` +Unstage a stagged file or file which is staged +``` shell script +$ git restore --staged [file] +``` Unstages file, keeping the file changes ``` shell script