Click here to Skip to main content
15,903,201 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Form Designer requires first class - VS2005 Pin
George L. Jackson3-Oct-07 17:27
George L. Jackson3-Oct-07 17:27 
Questionquestion about thread C++ Pin
argun222-Oct-07 12:24
argun222-Oct-07 12:24 
AnswerRe: question about thread C++ Pin
Christian Graus2-Oct-07 13:39
protectorChristian Graus2-Oct-07 13:39 
QuestionForum help Pin
smartiejoe30-Sep-07 0:23
smartiejoe30-Sep-07 0:23 
AnswerRe: Forum help Pin
Malcolm Smart30-Sep-07 0:50
Malcolm Smart30-Sep-07 0:50 
GeneralRe: Forum help Pin
Mark Salsbery30-Sep-07 7:12
Mark Salsbery30-Sep-07 7:12 
AnswerRe: Forum help Pin
George L. Jackson30-Sep-07 2:02
George L. Jackson30-Sep-07 2:02 
QuestionQuestions about reading binary files [modified] Pin
GentooGuy28-Sep-07 13:47
GentooGuy28-Sep-07 13:47 
Hi
I've got a jpg file which I'd like to read.
When using od in UNIX, I can get a hex version of its contents:

$ od -x file.jpg  | head<br />
0000000      d8ff    e1ff    8711    7845    6669    0000    4949    002a<br />
0000020      0008    0000    000b    010e    0002    0015    0000    0092<br />
0000040      0000    010f    0002    0018    0000    00b2    0000    0110<br />
0000060      0002    0005    0000    00d2    0000    0112    0003    0001<br />
0000100      0000    0001    0000    011a    0005    0001    0000    00e2<br />
0000120      0000    011b    0005    0001    0000    00ea    0000    0128<br />

When using this simple program, most of the values I read have a strange value:
#include "stdafx.h"<br />
#include <iostream><br />
#include <fstream><br />
 <br />
using namespace std;<br />
ifstream::pos_type size;<br />
char * memblock;<br />
<br />
<br />
int main () <br />
{<br />
  ifstream file ("y:\\EXIF\\sanyo-vpcg250.jpg", ios::in|ios::binary);<br />
  if (file.is_open())<br />
  {<br />
    size = file.tellg();<br />
    memblock = new char [size];<br />
    file.seekg (0, ios::beg);<br />
    file.read (memblock, size);<br />
    file.close();<br />
<br />
    cout << "the complete file content is in memory";<br />
	<br />
	char x=memblock[0];<br />
    delete[] memblock;<br />
  }<br />
  else cout << "Unable to open file";<br />
  return 0;<br />
}


The x value becomes 0xfd in the debugger (in vs.net using windows xp).
What's going wrong? And how can I get an output like the one using od?


-- modified at 19:58 Friday 28th September, 2007

Woops, should be moved to: http://www.codeproject.com/script/comments/forums.asp?forumid=1647
AnswerRe: Questions about reading binary files Pin
Mark Salsbery28-Sep-07 15:16
Mark Salsbery28-Sep-07 15:16 
AnswerRe: Questions about reading binary files Pin
Mark Salsbery28-Sep-07 15:22
Mark Salsbery28-Sep-07 15:22 
GeneralRe: Questions about reading binary files Pin
GentooGuy29-Sep-07 7:25
GentooGuy29-Sep-07 7:25 
GeneralRe: Questions about reading binary files Pin
Mark Salsbery29-Sep-07 7:39
Mark Salsbery29-Sep-07 7:39 
QuestionRe: Questions about reading binary files Pin
GentooGuy29-Sep-07 8:05
GentooGuy29-Sep-07 8:05 
AnswerRe: Questions about reading binary files Pin
Mark Salsbery29-Sep-07 8:22
Mark Salsbery29-Sep-07 8:22 
GeneralRe: Questions about reading binary files Pin
GentooGuy29-Sep-07 8:52
GentooGuy29-Sep-07 8:52 
GeneralRe: Questions about reading binary files Pin
Luc Pattyn29-Sep-07 9:15
sitebuilderLuc Pattyn29-Sep-07 9:15 
GeneralRe: Questions about reading binary files Pin
GentooGuy29-Sep-07 9:20
GentooGuy29-Sep-07 9:20 
GeneralRe: Questions about reading binary files Pin
Mark Salsbery29-Sep-07 9:16
Mark Salsbery29-Sep-07 9:16 
GeneralRe: Questions about reading binary files Pin
GentooGuy29-Sep-07 9:20
GentooGuy29-Sep-07 9:20 
GeneralRe: Questions about reading binary files Pin
GentooGuy29-Sep-07 10:27
GentooGuy29-Sep-07 10:27 
GeneralRe: Questions about reading binary files Pin
GentooGuy29-Sep-07 10:52
GentooGuy29-Sep-07 10:52 
GeneralRe: Questions about reading binary files [modified*2] Pin
Mark Salsbery29-Sep-07 11:08
Mark Salsbery29-Sep-07 11:08 
GeneralRe: Questions about reading binary files [modified*2] Pin
GentooGuy30-Sep-07 2:40
GentooGuy30-Sep-07 2:40 
GeneralRe: Questions about reading binary files Pin
Mark Salsbery30-Sep-07 6:31
Mark Salsbery30-Sep-07 6:31 
GeneralRe: Questions about reading binary files Pin
GentooGuy30-Sep-07 6:37
GentooGuy30-Sep-07 6:37 

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.