So far, I know that cin >> lets me input to a variable of any type... is that correct?
I'm not really sure what's the "proper" way of using cin... So, even though I'm programming C++, I tend to use some of "C's way" of inputting data...
- If I want to input to a string variable / character string array, I'd use:
- If I want to input to a character variable, I'd use:Code:fgets([varname], sizeof([varname]), stdin);
- If I want to input to an integer variable, I'd use:Code:[character variable] = getchar();
- If I want to input to a float / double variable, I'd use:Code:scanf("%i", &[variablename]);
- If I want to input [EDIT: "output" NOT input... lol] to a float / double variable WITH precision, I'd use:Code:scanf("%f", &[variablename]); // %lf for double
[EDIT: NEW CODE... -_+]
...obviously that's not the C++ way, so I would like to ask you people how am I going to those stuffs above using the C++ way... are there any cin equivalent for that? Thanks in advance and God bless...Code:printf("The output: %.2f", [variablename]); // %.2lf for double