Click here to Skip to main content
15,889,096 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Handles Pin
CPallini17-Dec-06 7:33
mveCPallini17-Dec-06 7:33 
GeneralRe: Handles Pin
BlitzPackage17-Dec-06 8:38
BlitzPackage17-Dec-06 8:38 
AnswerRe: Handles Pin
Stephen Hewitt17-Dec-06 11:39
Stephen Hewitt17-Dec-06 11:39 
AnswerRe: Handles Pin
nmap.terren17-Dec-06 14:19
nmap.terren17-Dec-06 14:19 
QuestionHow to get the CEdit box to update Pin
FredrickNorge17-Dec-06 5:32
FredrickNorge17-Dec-06 5:32 
AnswerRe: How to get the CEdit box to update Pin
BlitzPackage17-Dec-06 6:52
BlitzPackage17-Dec-06 6:52 
GeneralRe: How to get the CEdit box to update Pin
FredrickNorge17-Dec-06 7:05
FredrickNorge17-Dec-06 7:05 
Questionpointers to functions Pin
emrah.a17-Dec-06 3:58
emrah.a17-Dec-06 3:58 
Hi,

I am new to c++ and I will use it in my thesis on image processing.

I wrote a piece of code to read a ppm image file. in order to read the magic number (the number indicating the type of the image file whether it is ppm, bmp, jpeg or etc. this magic number is in the header section of the image) i create a char pointer magicNumber:

char *magicNumber;<br />
magicNumber = new char[2];// my aim is to create a pointer just to copy the "P6", i tried using malloc, but it did not fix 


and pass it into the function PPMreadHeader. My intent is to fill the pointer inside the function and write the magicnumber in the console outside the function.

i have an array in the PPMreadHeader fuinction in order to read the file line by line. I have a local char pointer "word":
<br />
char line[255];<br />
char * word;


when i read the magicnumber (it is "P6" for ppm files) i assign it to the local pointer word:

word=line;

if i try to write the magic number in the function using the local pointer:

cout<<word<<endl;

there is no problem, it writes p6 to the console. however, if i first copy the word into the magicnumber pointer that i create in the main function:

*magicNumber=*word;<br />
*(magicNumber+1)=*(word+1);



and then try to print out the pointer to the consolelike below:

cout<<"magicNumber: "<<magicNumber<<endl;

then it writes:

magicNumber:P6ııııİİ

which not i want. it writes the p6 which is what i want to write to the console, but it writes more than p6. within the function when i write the local pointer "word" it just writes the P6, nothing more. Could you please help me on this.

You may advise other alternatives to write the magic number on to the console but even you do this, i still want to learn what is wrong with my coding. i spent a lot of time on this and i could not fix it.

Thank you in advance.
AnswerRe: pointers to functions Pin
Chris Losinger17-Dec-06 4:43
professionalChris Losinger17-Dec-06 4:43 
AnswerRe: pointers to functions Pin
prasad_som17-Dec-06 18:22
prasad_som17-Dec-06 18:22 
GeneralNeed Article Co-Author Pin
Jeffrey Walton17-Dec-06 3:09
Jeffrey Walton17-Dec-06 3:09 
QuestionDouble buffering in a wmp Visualization Pin
ceejeeb17-Dec-06 3:08
ceejeeb17-Dec-06 3:08 
QuestionBest way to interact with a C program Pin
Luís Brás17-Dec-06 1:59
Luís Brás17-Dec-06 1:59 
AnswerRe: Best way to interact with a C program Pin
Mark Salsbery17-Dec-06 8:58
Mark Salsbery17-Dec-06 8:58 
QuestionSend enter key? Pin
Larsson17-Dec-06 1:35
Larsson17-Dec-06 1:35 
AnswerRe: Send enter key? Pin
Daniel Kanev17-Dec-06 2:48
Daniel Kanev17-Dec-06 2:48 
QuestionDLL Coding Dilemma... Pin
Shy Agam16-Dec-06 22:52
Shy Agam16-Dec-06 22:52 
AnswerRe: DLL Coding Dilemma... Pin
peterchen17-Dec-06 0:04
peterchen17-Dec-06 0:04 
GeneralRe: DLL Coding Dilemma... Pin
Shy Agam17-Dec-06 0:18
Shy Agam17-Dec-06 0:18 
GeneralRe: DLL Coding Dilemma... Pin
peterchen17-Dec-06 0:46
peterchen17-Dec-06 0:46 
GeneralRe: DLL Coding Dilemma... Pin
Shy Agam17-Dec-06 1:56
Shy Agam17-Dec-06 1:56 
QuestionHow to save HBITMAP into *.png?? Pin
314159265316-Dec-06 18:05
314159265316-Dec-06 18:05 
AnswerRe: How to save HBITMAP into *.png?? Pin
Hadi Dayvary16-Dec-06 18:41
professionalHadi Dayvary16-Dec-06 18:41 
QuestionRom loaders. Pin
asp.netProgrammer16-Dec-06 17:26
asp.netProgrammer16-Dec-06 17:26 
AnswerRe: Rom loaders. Pin
Jeffrey Walton17-Dec-06 3:31
Jeffrey Walton17-Dec-06 3:31 

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.