Skip to content

A program to learn C++ pointers, pointers arithmetic, dynamic memory allocation with pointers...

License

Notifications You must be signed in to change notification settings

00-Python/Learning-Cpp-Pointers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Learning C++ Pointers

This project is designed to teach you the basics of pointers in C++. Pointers are variables that store the memory address of another variable. They are used for dynamic memory allocation, accessing array elements, and creating data structures.

To get started, clone the repository and compile the code.

Table of Contents

How to Compile and Run

Windows

To compile the code on Windows, you can use an IDE like Visual Studio or a command-line compiler like MinGW. Follow these steps:

  1. Open the command prompt.
  2. Navigate to the project directory.
  3. Compile the code using the following command:
    g++ pointers.cpp -o pointers
    
    This command will generate an executable file named "pointers.exe".
  4. Run the compiled program by entering:
    pointers.exe
    

Linux

To compile the code on Linux, you can use the GNU Compiler Collection (GCC) which is usually pre-installed. Follow these steps:

  1. Open the terminal.
  2. Navigate to the project directory.
  3. Compile the code using the following command:
    g++ pointers.cpp -o pointers
    
    This command will generate an executable file named "pointers".
  4. Run the compiled program by entering:
    ./pointers
    

Level 1: Introduction to Pointers

In this level, you'll learn the basics of pointers. A pointer is declared using the '*' symbol followed by the data type it points to. Pointers allow indirect access to the value of the variable they point to.

Level 2: Pointer Arithmetic and Arrays

In this level, you'll learn about pointer arithmetic and arrays. Pointer arithmetic involves adding or subtracting an integer to/from a pointer, which moves the pointer to the next or previous memory location. Arrays in C++ are implemented using pointers, where the name of the array points to the first element.

Level 3: Dynamic Memory Allocation with Pointers

In this level, you'll learn about dynamic memory allocation with pointers. Dynamic memory allocation allows you to allocate memory at runtime, which is useful when you need to create arrays or objects whose size is not known at compile time. The 'new' operator is used to dynamically allocate memory, and the 'delete' operator is used to free the allocated memory.

Have fun learning about pointers!

About

A program to learn C++ pointers, pointers arithmetic, dynamic memory allocation with pointers...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages