First semester CS major here - I was absent from class once a while back and now that we're referencing the material I missed, I'm a little clueless. I have no friends so I figured I'd ask you guys.
Basically put, I'm having a little trouble how ifstream objects work. Before this segment of code, I've successfully opened a file and assigned it to ifstream variable "infile," but I don't know how I'm supposed to use it.
for (i = 1; i<= 3; i++)
{
getInputs (infile, l, w);
a = getArea (l, w);
displayArea (l, w, a);
}
I'm fine with the functions displayArea and getArea, but this is what I'm working off of with getInputs and I'm a little stumped.
I realize this fragment is probably retarded but I'm clueless - I'd appreciate any help you can give me.
Name:
Anonymous2012-04-30 19:55
Cast it to a double and then return EXIT_SUCCESS. Good luck!
Name:
Anonymous2012-04-30 19:55
Where the fuck do these retards come from?
I know it's not /prog/ because nobody could have been browsing for this long and not learn at least something.
Name:
Anonymous2012-04-30 20:40
Thanks for nothing, shitheads. This is my first time on /prog/ and I've been taking programming classes for about two months now - I know it's basic material, but it's just what we've been over in class. I'm not going to grovel or act like a bitch to get some help, I'll just figure it out on my own.
Obviously, getInputs is a void function, and any other miscellaneous retardations I either have no excuse for or chalk up to informality. My basic question is this: in the code fragment
inputFile >> length >> width;
the extraction operator works on the text file referenced by the ifstream object inputFile and assigns value to the variables length and width. And since I called them by reference, they should overwrite the value on their corresponding aliases in the main code, right?
Am I that far off base here? I just want to fucking understand this shit.
>>4
In case you haven't noticed, /prog/ isn't exactly the fastest board there is. Chances are you're going to need to wait longer than an hour to get a good response.
However, I would be surprised if anybody helped you now after that little tantrum. Now fuck off.
>>4
To get a clue about what the >> operator does in case of ifstream, check the documentation. Since this is C++ you can assume from the beginning that what you see will be absolutely retarded.
ifstream& operator>>(ifstream&, some type here&);
What it does is read from the ifstream, in a type-specific way, into the second argument. The return value is the changed ifstream (which is actually just the same ifstream with some changed state). The reason for the return value is simply for making reading chainable.
So (inputFile >> length) return an ifstream which then has operator>> called on it with `width' as an argument.
By now you should be puking blood
Name:
Anonymous2012-05-01 13:35
>>13
no it maek me turn on boner
i want wqork as program mer because :
i ca n do thing like this:
function VeryGoodporgamram(){
return VeryGooDporograom(LOLRECURSIOOINONA=DSN=(=)
}
Haxxr0e3d!