Click here to Skip to main content
15,909,896 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralTrying to capture and print the screen. Pin
GD30-Nov-01 14:50
GD30-Nov-01 14:50 
GeneralRe: Trying to capture and print the screen. Pin
Nish Nishant30-Nov-01 15:00
sitebuilderNish Nishant30-Nov-01 15:00 
GeneralRe: Trying to capture and print the screen. Pin
Rick York30-Nov-01 17:56
mveRick York30-Nov-01 17:56 
GeneralRichedit2.dll / Richedit32.dll Pin
Nnamdi Onyeyiri30-Nov-01 12:42
Nnamdi Onyeyiri30-Nov-01 12:42 
GeneralRe: Richedit2.dll / Richedit32.dll Pin
Henry Jacobs1-Dec-01 4:54
Henry Jacobs1-Dec-01 4:54 
GeneralFile Encryption & Read/Write in Binary Mode Pin
valikac30-Nov-01 12:28
valikac30-Nov-01 12:28 
GeneralRe: File Encryption & Read/Write in Binary Mode Pin
Nnamdi Onyeyiri30-Nov-01 12:35
Nnamdi Onyeyiri30-Nov-01 12:35 
GeneralRe: File Encryption & Read/Write in Binary Mode Pin
Anders Molin30-Nov-01 12:43
professionalAnders Molin30-Nov-01 12:43 
Instead of

char *temp; 
temp = new char(size); 

openFile.read((char *) temp, sizeof(temp)); 


use

char *temp; 
temp = new char(size); 

openFile.read(temp, size); 


sizeof(temp) is always going to return 4 because it's a pointer. There's actually no way to say "how many bytes is there allocated for this pointer", so you just have to remember it for yourself...

kuphryn wrote:
How do you read raw data (binary) from any file and save it in memory so you can make specific encryption and then write it back in binary mode?

I always use fread() and fwrite() for that Smile | :)

Just open the file as binary, and put it in a buffer with fread()

Here is a simple function that writes a binary file...

bool SaveBinaryFile(const char *filename, const char *buffer, const int buflen)
{
  FILE *f = fopen(filename, "wb");
  if (f == NULL) return false;
  unsigned int i = fwrite(buffer, sizeof(char), buflen, f);
  fclose(f);
  if ((signed)i != buflen) return false;
  return true;
}


- Anders

Money talks, but all mine ever says is "Goodbye!"
GeneralRe: File Encryption & Read/Write in Binary Mode Pin
valikac1-Dec-01 12:37
valikac1-Dec-01 12:37 
GeneralRe: File Encryption & Read/Write in Binary Mode Pin
Anders Molin1-Dec-01 12:42
professionalAnders Molin1-Dec-01 12:42 
GeneralRe: File Encryption & Read/Write in Binary Mode Pin
valikac3-Dec-01 12:44
valikac3-Dec-01 12:44 
GeneralAnother way to get the size of a file Pin
Ravi Bhavnani1-Dec-01 13:36
professionalRavi Bhavnani1-Dec-01 13:36 
GeneralSetting a different font for an application Pin
billb211230-Nov-01 11:00
billb211230-Nov-01 11:00 
Questionopengl + dll??? Pin
Kuniva30-Nov-01 10:21
Kuniva30-Nov-01 10:21 
GeneralMinimize Pin
kakuni30-Nov-01 9:58
kakuni30-Nov-01 9:58 
GeneralRe: Minimize Pin
Ravi Bhavnani30-Nov-01 10:39
professionalRavi Bhavnani30-Nov-01 10:39 
GeneralRe: Minimize Pin
kakuni30-Nov-01 11:06
kakuni30-Nov-01 11:06 
GeneralRe: Minimize Pin
Fazlul Kabir30-Nov-01 11:19
Fazlul Kabir30-Nov-01 11:19 
Generaldear god help me Pin
Abadon30-Nov-01 9:36
Abadon30-Nov-01 9:36 
GeneralRe: dear god help me Pin
Chris Losinger30-Nov-01 9:47
professionalChris Losinger30-Nov-01 9:47 
GeneralRe: dear god help me Pin
Fazlul Kabir30-Nov-01 9:59
Fazlul Kabir30-Nov-01 9:59 
GeneralRe: dear god help me Pin
Chris Losinger30-Nov-01 10:57
professionalChris Losinger30-Nov-01 10:57 
GeneralRe: dear god help me Pin
Nish Nishant30-Nov-01 14:55
sitebuilderNish Nishant30-Nov-01 14:55 
GeneralRe: dear god help me Pin
ColinDavies30-Nov-01 16:52
ColinDavies30-Nov-01 16:52 
GeneralRe: dear god help me Pin
Nish Nishant30-Nov-01 18:38
sitebuilderNish Nishant30-Nov-01 18:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.