Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalproblem with old code about pointer!!! Pin
lewislewis_lewis25-Jun-04 9:17
lewislewis_lewis25-Jun-04 9:17 
GeneralRe: problem with old code about pointer!!! Pin
David Crow25-Jun-04 9:51
David Crow25-Jun-04 9:51 
GeneralRe: problem with old code about pointer!!! Pin
lewislewis_lewis25-Jun-04 10:00
lewislewis_lewis25-Jun-04 10:00 
GeneralRe: problem with old code about pointer!!! Pin
David Crow25-Jun-04 10:30
David Crow25-Jun-04 10:30 
GeneralRe: problem with old code about pointer!!! Pin
Anonymous25-Jun-04 15:34
Anonymous25-Jun-04 15:34 
GeneralRe: problem with old code about pointer!!! Pin
Michael Dunn25-Jun-04 9:59
sitebuilderMichael Dunn25-Jun-04 9:59 
GeneralRe: problem with old code about pointer!!! Pin
Jeremy Falcon25-Jun-04 12:13
professionalJeremy Falcon25-Jun-04 12:13 
GeneralRe: problem with old code about pointer!!! Pin
Jeremy Falcon25-Jun-04 12:10
professionalJeremy Falcon25-Jun-04 12:10 
lewislewis_lewis wrote:
char *p = "Hello";

That's a huge no-no for a number of reasons, and a memory error waiting to happen. For one, if you don't allocate your memory, you're not guaranteed to have it available for your program to use.

Instead Func() should look like this:

void Func()
{
    char p[] = "Hello";
    *p = 'h';
}
In this instance, *p acts just like p[0].

Jeremy Falcon
GeneralTemporary File! Pin
mostafa_pasha25-Jun-04 8:16
mostafa_pasha25-Jun-04 8:16 
GeneralRe: Temporary File! Pin
David Crow25-Jun-04 9:01
David Crow25-Jun-04 9:01 
QuestionMultiline edit box ?? Pin
Spank me!!25-Jun-04 8:11
Spank me!!25-Jun-04 8:11 
AnswerRe: Multiline edit box ?? Pin
valikac25-Jun-04 8:25
valikac25-Jun-04 8:25 
AnswerRe: Multiline edit box ?? Pin
David Crow25-Jun-04 9:00
David Crow25-Jun-04 9:00 
AnswerRe: Multiline edit box ?? Pin
Christopher Lloyd25-Jun-04 9:02
Christopher Lloyd25-Jun-04 9:02 
AnswerRe: Multiline edit box ?? Pin
Ravi Bhavnani26-Jun-04 4:55
professionalRavi Bhavnani26-Jun-04 4:55 
Questionsse2 intrinsics question? Pin
Anand RK25-Jun-04 7:57
Anand RK25-Jun-04 7:57 
AnswerRe: sse2 intrinsics question? Pin
Christopher Lloyd25-Jun-04 10:05
Christopher Lloyd25-Jun-04 10:05 
GeneralRe: sse2 intrinsics question? Pin
Anand RK25-Jun-04 11:20
Anand RK25-Jun-04 11:20 
GeneralRe: sse2 intrinsics question? Pin
Anand RK25-Jun-04 15:08
Anand RK25-Jun-04 15:08 
GeneralRe: sse2 intrinsics question? Pin
Christopher Lloyd25-Jun-04 15:08
Christopher Lloyd25-Jun-04 15:08 
GeneralFileDialog and ActiveX Pin
TUMB25-Jun-04 7:40
TUMB25-Jun-04 7:40 
GeneralOpen Excutable Program in VC Pin
mostafa_pasha25-Jun-04 7:34
mostafa_pasha25-Jun-04 7:34 
GeneralRe: Open Excutable Program in VC Pin
User 665825-Jun-04 7:50
User 665825-Jun-04 7:50 
Generalinline vs macro Pin
BengCésar25-Jun-04 5:10
BengCésar25-Jun-04 5:10 
GeneralRe: inline vs macro Pin
Antony M Kancidrowski25-Jun-04 6:23
Antony M Kancidrowski25-Jun-04 6:23 

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.