What I was trying to do is, when I assigned 0x101112 to an address in memory, I thought it would first assign to 0x10 to the first element of the array, then 0x11 to the second element and so on. All...
Type: Posts; User: dhuan
What I was trying to do is, when I assigned 0x101112 to an address in memory, I thought it would first assign to 0x10 to the first element of the array, then 0x11 to the second element and so on. All...
Thought it had something to do with endianess. Guess I was on the wrong track, thanks for your explanation, grumpy
#include <iostream>
using namespace std;
int main()
{
char * c = new char[1];
*(c+0) = 0x10;
*(c+1) = 0x11;
unsigned int i = *(c);
#include <iostream>
using namespace std;
int main()
{
char * c = new char[2];
*c = 0x101112;
unsigned int i = *(c);
cout << i;
You mean, using FILE data type instead of fstream class?
So instead of "new char[lenght]", I would have to use something like "new char[lenght + 1]", since '\0' takes 1 byte, correct?
...
After doing some reading on FILE data type I decided to practice, I came up with this little program that reads any part of any file:
#include <iostream>
#include <string>
#include <stdio.h>...
Bump
Please, give me an example.
How could I not have seen it before. Thanks. I'll apply it to my code.
Yeh, I'm sure there's many ways of doing this much better than what I did, that's why...
What this function (hex_str) does is, it receives a 1-byte char as argument, and returns its hex representation as string.
I'd like some tips on how to improve my code.
#include <iostream>...
I've learned LZ77 in theory, know I wanna practice, my first attempt was to code a C++ function that finds the best match when comparing the sliding window with the look ahead buffer, this is what i...
Bump
Let's say i have a simple archive file, i've figured its format, headers etc ) thru hexadecimal editor.
Now whats the best approach for manipulating it in C++, like inserting a new file on it,...
This is its objective:
It asks for the name and salary of a specific number of employees... Then it calculates and tells the user the average salary of the company, then it says who's the richest...
Bump
After reading a tutorial on XOR encryption at cplusplus.com I decided to code
this super program called X-Encrypter, just so I can practice what I've learned
from tutorials.
This is what it does:...
Works fine, but when the key string is one or two characters long my CPU beeps.
Why does that happen?
#include <iostream>
#include <string>
using namespace std;
I dont understand. How does the modulo operator help?
Is this a valid xor encryption function?
#include <iostream>
#include <string>
using namespace std;
void xorEncrypt(string& str, string key)
{
This function returns a binary representation in string form, of a given integer.
#include <iostream>
#include <string>
using namespace std;
string int2bin(int num)
still, it's not clear to me why the OR bit operator doesnt work as it should.
I'll even write a simpler code that makes the compiler reports the same error message:
#include <iostream>...
After finishing reading a tutorial on bit flags, i decided to do some practicing.
Here's what I came up with:
#include <iostream>
#include <string>
using namespace std;
I'm reading about bit input/output on this link:
Bit input/output
It says:
But then:
laserlight, thank you! I could never figure out that the solution to this problem was a simple c_str() function that trasnforms the c++ string into a dummie c char.
Now, my next question is: how...
Another question, why can't the fstream constructor accept a string as the filename?
Here's what I tried:
string fileName;
cout<<"FILE:";
cin>>fileName;
fstream...
I still havent figured out how to write hex value to the file...
here's what i tried:
myFile.put(0xFF,1);
i only accepts char type data as argument...