Click here to Skip to main content
15,905,782 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: stack error in char array Pin
«_Superman_»31-May-11 4:03
professional«_Superman_»31-May-11 4:03 
GeneralRe: stack error in char array Pin
Chuck O'Toole31-May-11 6:48
Chuck O'Toole31-May-11 6:48 
GeneralRe: stack error in char array Pin
Stefan_Lang31-May-11 22:59
Stefan_Lang31-May-11 22:59 
GeneralRe: stack error in char array Pin
«_Superman_»31-May-11 23:01
professional«_Superman_»31-May-11 23:01 
AnswerRe: stack error in char array Pin
Stefan_Lang30-May-11 22:40
Stefan_Lang30-May-11 22:40 
AnswerRe: stack error in char array Pin
Chuck O'Toole31-May-11 1:54
Chuck O'Toole31-May-11 1:54 
GeneralRe: stack error in char array Pin
Stefan_Lang31-May-11 23:03
Stefan_Lang31-May-11 23:03 
GeneralRe: stack error in char array Pin
MicroVirus1-Jun-11 2:15
MicroVirus1-Jun-11 2:15 
GeneralRe: stack error in char array Pin
Chuck O'Toole1-Jun-11 2:43
Chuck O'Toole1-Jun-11 2:43 
GeneralRe: stack error in char array Pin
Stefan_Lang1-Jun-11 3:15
Stefan_Lang1-Jun-11 3:15 
QuestionWhy my 64 architecture exe is not able to read registry? Pin
rahul.kulshreshtha30-May-11 2:51
rahul.kulshreshtha30-May-11 2:51 
AnswerRe: Why my 64 architecture exe is not able to read registry? Pin
MicroVirus30-May-11 3:29
MicroVirus30-May-11 3:29 
GeneralRe: Why my 64 architecture exe is not able to read registry? Pin
rahul.kulshreshtha30-May-11 3:34
rahul.kulshreshtha30-May-11 3:34 
GeneralRe: Why my 64 architecture exe is not able to read registry? Pin
MicroVirus30-May-11 3:46
MicroVirus30-May-11 3:46 
AnswerRe: Why my 64 architecture exe is not able to read registry? Pin
Rolf Kristensen30-May-11 6:17
Rolf Kristensen30-May-11 6:17 
QuestionProblem with Imagelist_LoadBitmap Pin
Cold_Fearing_Bird29-May-11 7:26
Cold_Fearing_Bird29-May-11 7:26 
AnswerRe: Problem with Imagelist_LoadBitmap Pin
Niklas L29-May-11 8:39
Niklas L29-May-11 8:39 
QuestionPassing char* to a function and change the argument problem Pin
.jpg29-May-11 6:24
.jpg29-May-11 6:24 
AnswerRe: Passing char* to a function and change the argument problem Pin
CPallini29-May-11 6:38
mveCPallini29-May-11 6:38 
AnswerRe: Passing char* to a function and change the argument problem Pin
Richard MacCutchan29-May-11 13:26
mveRichard MacCutchan29-May-11 13:26 
GeneralRe: Passing char* to a function and change the argument problem Pin
MicroVirus30-May-11 3:37
MicroVirus30-May-11 3:37 
GeneralRe: Passing char* to a function and change the argument problem Pin
Richard MacCutchan30-May-11 4:13
mveRichard MacCutchan30-May-11 4:13 
GeneralRe: Passing char* to a function and change the argument problem Pin
MicroVirus30-May-11 4:39
MicroVirus30-May-11 4:39 
Unfortunately, it has everything to do with your answer and code. Even though the OP is obviously new to C/C++, it doesn't hurt to learn good practices right from the start.
At any rate, it wasn't a suggestion: it's me saying that it is bad practice to use pointers and string literals in that way, for the reasons I explained. This is quite independent of the programmer's intentions.

So my point is: your solution was almost correct, except for that you should use 'const char*' everywhere to work with it like this. This could potentially save the OP lots of time trying to debug weird access violation errors later on, as the compiler will be able to inform you when you are doing something inappropriate that you are allowed to do when just defining it as 'char*'.

Now if you think I am entirely wrong and that it is in fact not poor practice, then I'd love to hear your arguments.
AnswerRe: Passing char* to a function and change the argument problem Pin
«_Superman_»29-May-11 19:30
professional«_Superman_»29-May-11 19:30 
GeneralRe: Passing char* to a function and change the argument problem Pin
Richard MacCutchan29-May-11 22:49
mveRichard MacCutchan29-May-11 22:49 

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.