Hey guys I am learning c++ on my own I have few questions..
1. How can I store two different data Into two variables but from Single Input..
example:-
Cout<<"Enter YOU Name";
cin>>'First Name' 'Middle Name' 'Last Name' // user enters name
Now how do I store this in 3 Varibles.. 'Fn' ,' Mn' , 'Ln' Respectively
Example 2.
Cout<<"enter your Screen Rsolution :";
cin>> 1280 x 720
How do I store this in 2 Variables,.. Width and Hegiht
I know how to store this in Single variable .. guys pls reply ASAP
2. How can I store Two data types values in Single Array if not then what is alternate to store two different types of data in Single Variable
Example:
I wish to store string on first Element and Integers in Second Element..
cout<<"Enter your Name";
cin> > fn> > mn> > ln;
While giving data, press enter after giving first name & enter again for second & enter again for third. This stores data in respective variables.
2) Take two variables width & height.
cout<<" Enter width & height";
cin> > width> > height;
//if you prefer showing it as 1280x720
cout<<width<<"x"<<height;
Second option, you can use array to store dimensions, like an array for eg dim[2].
dim[0] = //width
dim[1] for height.
3) No you can't since array is a collection of items of similar type, you can't use two data types in an array, but in a string array it still accepts numbers, but considers them as strings.
For encapsulating variables of several data types, you have structures & classes.