Click here to Skip to main content
       

C / C++ / MFC

 
AnswerRe: compile code twice,why the two result is differrent Pinmembersajeesh.c30-Nov-12 18:28 
AnswerRe: compile code twice,why the two result is differrent PinmemberCristian Amarie3-Dec-12 8:55 
QuestionCListCtrl Pinmembersarfaraznawaz28-Nov-12 21:07 
AnswerRe: CListCtrl PinmemberJochen Arndt28-Nov-12 21:30 
QuestionLong pointer to character C++ Pinmemberpix_programmer28-Nov-12 4:41 
GeneralRe: Long pointer to character C++ PinmemberDavidCrow28-Nov-12 5:19 
AnswerRe: Long pointer to character C++ PinmvpRichard MacCutchan28-Nov-12 5:20 
AnswerRe: Long pointer to character C++ PinmemberStefan_Lang28-Nov-12 6:07 
pix_programmer wrote:
I'm reading some string from a XML file and assigning it to a <code>const char*</code> variable.

That doesn't make sense. A pointer can only be sensibly initialized within the program, at runtime, because only then does the computer know where in memeory every object lies. Therefore it doesn't make sense to either store or restore a pointer to/from a file!
 
What you need to do instead is:
1. read that string from your file
2. Allocate a char array on the heap that is big enough to contain that string (including the terminating NULL character!)
3. Assign that array to your pointer
4. Store the string in that char array.
 
Of course, if you use std::string, that would save you some of that efort.
GeneralRe: Long pointer to character C++ PinmemberDavidCrow28-Nov-12 7:56 
GeneralRe: Long pointer to character C++ PinmemberStefan_Lang28-Nov-12 22:03 
AnswerRe: Long pointer to character C++ PinmvpCPallini28-Nov-12 7:48 
AnswerRe: Long pointer to character C++ Pinmembersajeesh.c30-Nov-12 18:35 
AnswerRe: Long pointer to character C++ [modified] PinmemberApril Fans13-Dec-12 18:06 
Questionproblem in c with linux Pinmembera1_shay28-Nov-12 2:23 
AnswerRe: problem in c with linux PinmvpCPallini28-Nov-12 3:07 
SuggestionRe: problem in c with linux PinmvpRichard MacCutchan28-Nov-12 3:11 
GeneralRe: problem in c with linux Pinmembera1_shay28-Nov-12 21:35 
GeneralRe: problem in c with linux PinmvpRichard MacCutchan28-Nov-12 23:04 
AnswerRe: problem in c with linux Pinmembersajeesh.c30-Nov-12 18:40 
QuestionMerging Arrays Pinmemberpix_programmer27-Nov-12 21:57 
AnswerRe: Merging Arrays PinmemberAndy41127-Nov-12 22:48 
AnswerRe: Merging Arrays PinmvpCPallini27-Nov-12 23:09 
JokeRe: Merging Arrays PinmvpRichard MacCutchan27-Nov-12 23:45 
JokeRe: Merging Arrays PinmvpCPallini27-Nov-12 23:58 
GeneralRe: Merging Arrays PinmemberDavidCrow28-Nov-12 5:36 

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

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


Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 2 Oct 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid