Click here to Skip to main content
15,881,898 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWindows date change event Pin
Vijjuuu.12-Apr-10 20:40
Vijjuuu.12-Apr-10 20:40 
AnswerRe: Windows date change event Pin
David Crow13-Apr-10 2:56
David Crow13-Apr-10 2:56 
AnswerRe: Windows date change event Pin
KarstenK13-Apr-10 4:34
mveKarstenK13-Apr-10 4:34 
QuestionC - Application reusing memory locations that have been altered Pin
Member 259847812-Apr-10 13:35
Member 259847812-Apr-10 13:35 
AnswerRe: C - Application reusing memory locations that have been altered Pin
Garth J Lancaster12-Apr-10 15:09
professionalGarth J Lancaster12-Apr-10 15:09 
GeneralRe: C - Application reusing memory locations that have been altered Pin
Member 259847812-Apr-10 17:06
Member 259847812-Apr-10 17:06 
GeneralRe: C - Application reusing memory locations that have been altered Pin
Tim Craig12-Apr-10 17:42
Tim Craig12-Apr-10 17:42 
GeneralRe: C - Application reusing memory locations that have been altered Pin
enhzflep13-Apr-10 2:03
enhzflep13-Apr-10 2:03 
No, no, no, no! no.

In your example, you are sending the text as a constant - the compiler can do whatever it chooses to store/optimize constant usage. In my case something like that crashes...

What you should be doing is along the lines of:

#include <stdio.h>
#include <stdlib.h>

char *manip(char *manipMe)
{
    return strrev(manipMe);
}

int main()
{
    char *manipMe;

    manipMe = (char*)malloc(strlen("Hello world!\n")+1);
    strcpy(manipMe, "Hello world!\n");

    printf("%s","Hello world!\n");
//    printf("%s",manip("Hello world!\n"));     // crashes nuder mingw 3.4.5
//    printf("%s",manip("Hello world!\n"));     // crashes nuder mingw 3.4.5

    printf("%s",manip(manipMe));
    printf("%s",manip(manipMe));
    return 0;
}


Output:
Hello world!

!dlrow olleHHello world!

Process returned 0 (0x0)   execution time : 0.031 s
Press any key to continue.

AnswerRe: C - Application reusing memory locations that have been altered Pin
Eugen Podsypalnikov12-Apr-10 20:34
Eugen Podsypalnikov12-Apr-10 20:34 
QuestionDLL in memory Pin
RomTibi12-Apr-10 8:53
RomTibi12-Apr-10 8:53 
QuestionRe: DLL in memory Pin
David Crow12-Apr-10 10:11
David Crow12-Apr-10 10:11 
AnswerRe: DLL in memory Pin
RomTibi13-Apr-10 6:35
RomTibi13-Apr-10 6:35 
AnswerRe: DLL in memory Pin
David Crow13-Apr-10 6:40
David Crow13-Apr-10 6:40 
GeneralRe: DLL in memory Pin
RomTibi13-Apr-10 6:55
RomTibi13-Apr-10 6:55 
GeneralRe: DLL in memory Pin
David Crow13-Apr-10 6:57
David Crow13-Apr-10 6:57 
GeneralRe: DLL in memory Pin
RomTibi13-Apr-10 6:59
RomTibi13-Apr-10 6:59 
AnswerRe: DLL in memory Pin
«_Superman_»12-Apr-10 10:30
professional«_Superman_»12-Apr-10 10:30 
GeneralRe: DLL in memory Pin
RomTibi13-Apr-10 6:37
RomTibi13-Apr-10 6:37 
AnswerRe: DLL in memory Pin
@Intersect☺™12-Apr-10 19:39
professional@Intersect☺™12-Apr-10 19:39 
GeneralRe: DLL in memory Pin
RomTibi13-Apr-10 6:38
RomTibi13-Apr-10 6:38 
AnswerRe: DLL in memory Pin
Stephen Hewitt13-Apr-10 14:05
Stephen Hewitt13-Apr-10 14:05 
QuestionVisual Studio 6.0 (1998) VS Visual Studio .NET 2003 (Working on MFC) [modified] Pin
Mr. Tomay12-Apr-10 7:11
Mr. Tomay12-Apr-10 7:11 
AnswerRe: Visual Studio 6.0 (1998) VS Visual Studio .NET 2003 (using MFC) Pin
«_Superman_»12-Apr-10 7:39
professional«_Superman_»12-Apr-10 7:39 
AnswerRe: Visual Studio 6.0 (1998) VS Visual Studio .NET 2003 (using MFC) Pin
Maximilien12-Apr-10 7:49
Maximilien12-Apr-10 7:49 
GeneralRe: Visual Studio 6.0 (1998) VS Visual Studio .NET 2003 (using MFC) Pin
Mr. Tomay13-Apr-10 8:26
Mr. Tomay13-Apr-10 8:26 

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.