#include <iostream>
#include <string>
using namespace std;
struct car{
string name;
string color;
int maxSpeed;
int model;
};
car fun (car *x){
cout << "Name: " ;
cin >> x->name;
cout << "Model: ";
cin >> x->model;
cout << "Color: ";
cin >> x->color;
cout << "Maximum speed: ";
cin >> x->maxSpeed;
return *x;
}
int main(){
car c1;
fun (&c1);
car c2 = c1;
cout << "Name: " << c2.name <<endl;
cout << "Model: " << c2.model <<endl;
cout << "Color: " << c2.color <<endl;
cout << "Maximum speed: " << c2.maxSpeed <<endl;
}
#include <iostream>
#include <string>
using namespace std;
struct car{
string name;
string color;
int maxSpeed;
int model;
};
void fun (car x){
cout << "Name: " << x.name << endl;
cout << "Model: " << x.model << endl;
cout << "Color: " << x.color << endl;
cout << "Maximum speed: " << x.maxSpeed << endl;
}
int main(){
car c1 ={ "BMW","Red",200,2019 };
car *c2 = &c1;
cout << c2 -> color;
}
Code Example |
---|
Cpp :: c++ fill array with 0 |
Cpp :: c++std vector three elemet c++ |
Cpp :: c++ allocate and free dynamic 2d array |
Cpp :: how to print hello world in c++ |
Cpp :: c++ pause |
Cpp :: double max value c++ |
Cpp :: rotation to vector2 godot |
Cpp :: how to run code in devcpp |
Cpp :: qimage transformed |
Cpp :: capture an entire line C++ |
Cpp :: stock a file in a vector cpp |
Cpp :: c++ writing to file |
Cpp :: pyramid shape in c++ |
Cpp :: cout hex value |
Cpp :: c++ overwrite file |
Cpp :: c++ replace character in string |
Cpp :: C compile SDL program using mingw |
Cpp :: if not defined c++ |
Cpp :: n queens c++ |
Cpp :: input a string in c++ |
Cpp :: how to clear screen in C++ console |
Cpp :: easy c++ code |
Cpp :: initialize 2d array c++ memset |
Cpp :: mpi_bcast |
Cpp :: c++ shared pointer |
Cpp :: remove first element from vector c++ |
Cpp :: how to find length of character array in c++ |
Cpp :: http.begin not working |
Cpp :: c++ vector average |
Cpp :: int_max cpp |