Hello, I am relatively new to C++ (Been reading the documentation for maybe 3 days now?) but not coding in general. (Bit of Basic, but most of my syntax and relative experience comes from using GameMaker 6.0. Not the best place to learn but at least most of these concepts seem somewhat familiar.)
I've read and I believe I understand the concepts up to and through Dynamic Memory, but I can't be sure. Just hoping to have this stuff down pat before I continue to avoid learning something incorrectly and having it mess me up bad later.
Could somebody propose to me a program I could write to see if I really do understand these things? I guess I'm basically asking for homework. If at all possible it would be ideal if it would require very out-of-the-box thinking..
Normally a programming class would have this, but as it is the state of CA schools, they cut our entire computer sci. department down to a typing class and an HTML class...
Also, I've noticed that getline doesn't work correctly with Bloodshed Dev-C++? Maybe something's wrong with my settings but when I used getline instead of cin, the console did not wait for my input and instead closed down (I was under the impression it would wait for my input before continuing the program and reaching the end of main()). Can anyone recommend a good compiler with IDE options for keeping the console window open?
Write a program that completely loads a file to memory as binary, performs an XOR 0xFF on every bytes, then writes it back.
See the reference for std::istream::seekg(), std::istream::tellg(), std::istream::read(), and std::ostream::write() if you don't know them.
Also, I've noticed that getline doesn't work correctly with Bloodshed Dev-C++
That could be because there's already "something+newline(Enter)" inside input buffer. Try clearing the input buffer then ask for getline. Hope it helps.
Write a program that completely loads a file to memory as binary, performs an XOR 0xFF on every bytes, then writes it back.
See the reference for std::istream::seekg(), std::istream::tellg(), std::istream::read(), and std::ostream::write() if you don't know them.
Ahaha wow alright. I think I may just save the references onto my DS and read up on em at school today.
Thanks Helios. I will post back later today (... Expect a good 14 hours before I post again. School + Swim + Actually attempting.) with my progress.
Well; Zomgosh, here's my attempt I guess. I'll upload the first attempt, then I remember 'omg. I forgot to look up those functions.' So then I gave it a second attempt. Links to both follow >.>;;
You can KIND OF see that I was trying to manually set up those functions in my first try lololol... It's no wonder that I failed. Complex and inefficient at best even if I did get it to work I guess. 2nd try works. Spits out a file filled with weird little Y symbols the same length as the first file.
Notes: If you run it, please specify the directory of the new file as well. (C:\Documents and Settings\You\Desktop) <-- Or something of the like.
Looking back at that, when I found out there was a nice easy way to accomplish that, the proud 'AHA!' Factor didn't kick in. It was more of a.. 'Oh..' xD..
Ah well.
Is assigning bytes the value of 0xFF diff than an 'XOR 0xFF' ? I have no idea what an XOR is..
Write a short implementation of a file hierarchy. Small tip: a directory has the same properties as file, and more.
As a bonus, write a function that takes a path and loads to memory the file hierarchy under that path.
XOR is "The logical operation exclusive disjunction, also called exclusive or (symbolized XOR or EOR), is a type of logical disjunction on two operands ..."
It's the "exclusive OR", meaning it returns true only if ONE of the input values is true, and not both.
Example:
1 2 3 4 5
int one;
if ((one==1 && one!=2) || (one==2 && one!=1)) { /* If one does not equal 2 but equals 1 or
one is equal to 1 but not 2...*/
cout << "One equals: " << one << endl; // print "One equals: [one's value here]";
}