"jalkadir" <[EMAIL PROTECTED]> writes:
> void getData(){
> jme::Address address2;
> std::string str;
> char* cstr;
In general, it's a good idea to define variable where you initialize
them. If that's not possible, move the definition just above the
initialization.
Also, avoid overly long functions. I personally dislike functions of
>=10 lines - they are just longer that what I can easily grasp.
> std::cout.flush();
> //std::cin.get().flush();
>
> str.clear();
Pointless. str is already empty.
> std::cout << "House/Appartment # ";
> std::cin >> str;
As every input operation, this can fail. First check for success, then
use str. E.g.:
std::string str;
if (std::cin >> str)
; // use str
else
; // handle input failure
> std::cin.get(); // Without this line the program jumps <====
> address2.setUnitNumber(str);
>
>
>
> std::cout << "Enter street name: ";
> std::cin.get(cstr,255);
Starting here, your program has undefined behavior. cstr is read but
has never been initialized. That's one reason to define where you
initialize.
In this case, using a char * doesn't make sense, by the way. Use
std::string - this is what it was created for.
_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus