#include<iostream>
using namespace std;
int main(){
int* integerpointer;
float* floatpointer;
//dynamically allocating memory
integerpointer = new int;
floatpointer = new float;
//assigning values
*integerpointer = 12;
*floatpointer = 12.2;
//printing
cout << integerpointer<<endl;
cout << floatpointer<<endl;
cout << *integerpointer <<endl;
cout << *floatpointer<<endl;
//deallocating memory
delete integerpointer;
delete floatpointer;
}
///////////////////////////////////////// using objects////////////////////////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;
class student
{
int age;
public:
void getdata()
{
cout << "Enter your age?" << endl;
cin >> age;
}
void display()
{
cout << "The input age was " << age << endl;
}
};
int main()
{
student *sptr = new student();
sptr->getdata();
sptr->display();
// memory released
delete sptr;
}
////////////////////////////////////in C programming ////////////////////////////////////////////////////////////////
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include<stdio.h>
int main(){
int * x;
float * y;
x= (int *)malloc(n *sizeof(int));
y =(int *)calloc(n, sizeof(int));
}
Code Example |
---|
Cpp :: set(W) |
Cpp :: Temporary file using MSFT API in cpp |
Cpp :: http://nv-study.ru/http://nv-study.ru/http://nv-study.ru/ |
Cpp :: semi colon in argument list c++ |
Cpp :: stack using cpp |
Cpp :: initialize object as null in c++ |
Cpp :: std remove example |
Cpp :: GoPro camera for kids aus |
Cpp :: c++ cyclic barrier |
Cpp :: print an array c++ |
Cpp :: Tricky Subset Problem |
Cpp :: convert string to wide string |
Cpp :: pcl c++ read .pcd |
Cpp :: C++ (gcc 8.3) sample |
Cpp :: c++ rgb code |
Cpp :: c++ void pointer |
Cpp :: c++ ignore_line |
Cpp :: number triangle c++ |
Cpp :: void linux java |
Cpp :: vector übergeben c++ |
Cpp :: C++ Ranged Based for Loop |
Cpp :: how to display score using SDL in c++ |
Cpp :: how to use and in c++ |
Cpp :: C++ bool |
Cpp :: remove element from vector c++ by index |
Cpp :: c++ create vector of size |
Cpp :: c++ if else if |
Cpp :: c++ cin string |
Cpp :: how to make sound in c++ |
Cpp :: freeing array in c++ |