Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ Pointers to Structure

#include <iostream>
using namespace std;
struct Distance {
    int feet;
    float inch;
};
int main() {
    Distance *ptr, d;
    ptr = &d;
        cout << "Enter feet: ";
    cin >> (*ptr).feet;
    cout << "Enter inch: ";
    cin >> (*ptr).inch;
     cout << "Displaying information." << endl;
    cout << "Distance = " << (*ptr).feet << " feet " << (*ptr).inch << " inches";
    return 0;
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #Pointers #Structure
ADD COMMENT
Topic
Name
2+8 =