Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to access struct variables in c++

#include <iostream>
using namespace std;
 
struct Point {
    int x, y;
};
 
int main()
{
    struct Point p1 = { 1, 2 };
 
    // p2 is a pointer to structure p1
    struct Point* p2 = &p1;
 
    // Accessing structure members using
    // structure pointer
    cout << p2->x << " " << p2->y;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to hide ui elements unity 
Cpp :: how to make a 2d vector in c++ 
Cpp :: input a string in c++ 
Cpp :: c++ print byte as bit 
Cpp :: freopen c++ 
Cpp :: Matrix multiply using function c++ 
Cpp :: c++ check if file exits 
Cpp :: locate specific string letters c++ 
Cpp :: make random nuber between two number in c++ 
Cpp :: c++ vector iterator 
Cpp :: cannot open include file: 
Cpp :: string to integer convert c++ 
Cpp :: how to declare 1-D array in C/C++ 
Cpp :: lcm function c++ 
Cpp :: how to check is some number is divisible by 3 in c++ 
Cpp :: read file into vector 
Cpp :: copy 2 dimensional array c++ 
Cpp :: c++ iterate over vector 
Cpp :: max of two elements c++ 
Cpp :: initialize whole array to 0 c++ 
Cpp :: print vector of vector c++ 
Cpp :: c++ length of char array 
Cpp :: mkdir c++ 
Cpp :: cpp create multidimensional vector 
Cpp :: how to scan array in c++ 
Cpp :: c++ for else 
Cpp :: inbuilt function to convert decimal to binary in c++ 
Cpp :: delete from front in vector c++ 
Cpp :: console colors in C++ 
Cpp :: c++ code for bubble sort 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =