Click here to Skip to main content
15,434,217 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: compile code twice,why the two result is differrent Pin
Sajeesh Payolam30-Nov-12 18:28
MemberSajeesh Payolam30-Nov-12 18:28 
AnswerRe: compile code twice,why the two result is differrent Pin
Cristian Amarie3-Dec-12 8:55
MemberCristian Amarie3-Dec-12 8:55 
QuestionCListCtrl Pin
sarfaraznawaz28-Nov-12 21:07
Membersarfaraznawaz28-Nov-12 21:07 
AnswerRe: CListCtrl Pin
Jochen Arndt28-Nov-12 21:30
professionalJochen Arndt28-Nov-12 21:30 
QuestionLong pointer to character C++ Pin
pix_programmer28-Nov-12 4:41
Memberpix_programmer28-Nov-12 4:41 
GeneralRe: Long pointer to character C++ Pin
David Crow28-Nov-12 5:19
MemberDavid Crow28-Nov-12 5:19 
AnswerRe: Long pointer to character C++ Pin
Richard MacCutchan28-Nov-12 5:20
mveRichard MacCutchan28-Nov-12 5:20 
AnswerRe: Long pointer to character C++ Pin
Stefan_Lang28-Nov-12 6:07
mveStefan_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++ Pin
David Crow28-Nov-12 7:56
MemberDavid Crow28-Nov-12 7:56 
GeneralRe: Long pointer to character C++ Pin
Stefan_Lang28-Nov-12 22:03
mveStefan_Lang28-Nov-12 22:03 
AnswerRe: Long pointer to character C++ Pin
CPallini28-Nov-12 7:48
mveCPallini28-Nov-12 7:48 
AnswerRe: Long pointer to character C++ Pin
Sajeesh Payolam30-Nov-12 18:35
MemberSajeesh Payolam30-Nov-12 18:35 
AnswerRe: Long pointer to character C++ Pin
April Fans13-Dec-12 18:06
MemberApril Fans13-Dec-12 18:06 
Questionproblem in c with linux Pin
a1_shay28-Nov-12 2:23
Membera1_shay28-Nov-12 2:23 
AnswerRe: problem in c with linux Pin
CPallini28-Nov-12 3:07
mveCPallini28-Nov-12 3:07 
SuggestionRe: problem in c with linux Pin
Richard MacCutchan28-Nov-12 3:11
mveRichard MacCutchan28-Nov-12 3:11 
GeneralRe: problem in c with linux Pin
a1_shay28-Nov-12 21:35
Membera1_shay28-Nov-12 21:35 
GeneralRe: problem in c with linux Pin
Richard MacCutchan28-Nov-12 23:04
mveRichard MacCutchan28-Nov-12 23:04 
AnswerRe: problem in c with linux Pin
Sajeesh Payolam30-Nov-12 18:40
MemberSajeesh Payolam30-Nov-12 18:40 
QuestionMerging Arrays Pin
pix_programmer27-Nov-12 21:57
Memberpix_programmer27-Nov-12 21:57 
AnswerRe: Merging Arrays Pin
Andy41127-Nov-12 22:48
MemberAndy41127-Nov-12 22:48 
AnswerRe: Merging Arrays Pin
CPallini27-Nov-12 23:09
mveCPallini27-Nov-12 23:09 
JokeRe: Merging Arrays Pin
Richard MacCutchan27-Nov-12 23:45
mveRichard MacCutchan27-Nov-12 23:45 
JokeRe: Merging Arrays Pin
CPallini27-Nov-12 23:58
mveCPallini27-Nov-12 23:58 
GeneralRe: Merging Arrays Pin
David Crow28-Nov-12 5:36
MemberDavid Crow28-Nov-12 5:36 

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.