From 256fdbaf0aed07b8a02dc81389e50bc43f48a0f7 Mon Sep 17 00:00:00 2001 From: Aarul14 <52631289+Aarul14@users.noreply.github.com> Date: Sun, 9 Oct 2022 11:57:19 +0530 Subject: [PATCH 1/2] added the concept of character pointer --- cpp/pointers/pointers.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cpp/pointers/pointers.md b/cpp/pointers/pointers.md index 00ed6c6..c2b6e89 100644 --- a/cpp/pointers/pointers.md +++ b/cpp/pointers/pointers.md @@ -93,8 +93,32 @@ int main() return 0; } ``` + ### Check result [here](https://onecompiler.com/cpp/3yjazmygf) +## Example +```#include +using namespace std; + +int main(){ + int a[]={1,2,3}; + char b[]= "abc"; + + //in char array ptr, ptr does not store the address(unlike integer array) + //but instead prints the whole characters untill it find '\0' + + char *p = & b[0]; //prints abc + cout< Date: Sun, 9 Oct 2022 11:58:42 +0530 Subject: [PATCH 2/2] added the concept pf character pointer --- cpp/pointers/pointers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/pointers/pointers.md b/cpp/pointers/pointers.md index c2b6e89..0bd8434 100644 --- a/cpp/pointers/pointers.md +++ b/cpp/pointers/pointers.md @@ -97,11 +97,11 @@ int main() ### Check result [here](https://onecompiler.com/cpp/3yjazmygf) ## Example -```#include +```c +#include using namespace std; int main(){ - int a[]={1,2,3}; char b[]= "abc"; //in char array ptr, ptr does not store the address(unlike integer array)