Click here to Skip to main content
15,892,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: dear brother, can you tell me how to hook the messages of a short-cut menu? Pin
nenfa30-Nov-09 20:43
nenfa30-Nov-09 20:43 
AnswerRe: dear brother, can you tell me how to hook the messages of a short-cut menu? Pin
Richard MacCutchan30-Nov-09 22:25
mveRichard MacCutchan30-Nov-09 22:25 
GeneralRe: dear brother, can you tell me how to hook the messages of a short-cut menu? Pin
nenfa1-Dec-09 3:32
nenfa1-Dec-09 3:32 
GeneralRe: dear brother, can you tell me how to hook the messages of a short-cut menu? Pin
Richard MacCutchan1-Dec-09 5:31
mveRichard MacCutchan1-Dec-09 5:31 
GeneralRe: dear brother, can you tell me how to hook the messages of a short-cut menu? Pin
nenfa2-Dec-09 3:29
nenfa2-Dec-09 3:29 
GeneralRe: dear brother, can you tell me how to hook the messages of a short-cut menu? Pin
nenfa2-Dec-09 3:35
nenfa2-Dec-09 3:35 
GeneralRe: dear brother, can you tell me how to hook the messages of a short-cut menu? Pin
Richard MacCutchan2-Dec-09 4:46
mveRichard MacCutchan2-Dec-09 4:46 
QuestionTrim function for char pointer Pin
ggoutam730-Nov-09 19:47
ggoutam730-Nov-09 19:47 
Hello,

I am trying to create a trim function for char pointer. The lTrim can work perfectly. But, run time error occurs at rTrim.
Below is the error msg :
"Unhandled exception at 0x00411b37 in Test2.exe: 0xC0000005: Access violation writing location 0x00418cf7."

Full code provided below :
<code>
// <stdio.h>
// <conio.h>
// <iostream>
#include <stdio.h>     
#include <conio.h>    
#include <iostream> 

using namespace std;

int isspace ( char c );
char * lTrim ( char * p );
char * rTrim ( char * p );
char * Trim( char * p );

int isspace ( char c )
{
   return c == ' '  || c == '\t' ||
          c == '\v' || c == '\f'  ;
}

char * lTrim ( char * p )
{
    while ( p && isspace(*p) ) ++p ;
    return p ;
}

char * rTrim ( char * p )
{
    char * temp = 0;
    if (!p) return p;
    temp = (char *)(p + strlen(p)-1);
    while ( (temp>=p) && isspace(*temp) ) --temp;
    *(temp+1) = '\0';  // Run time error occurs here

    return p;
}

char * Trim( char * p )
{
    return lTrim(rTrim(p));
}

int main()
{ 
	char * str = "  This is utterly brilliant  ";

	printf(">>%s<<\n", str);
	str = Trim(str);
	printf(">>%s<<\n", str);

	getch();
	return 0;
}
</code>

Your guidance on solving this problem is very much appreciated.

Thanks,
Goutam
AnswerRe: Trim function for char pointer Pin
«_Superman_»30-Nov-09 20:03
professional«_Superman_»30-Nov-09 20:03 
GeneralRe: Trim function for char pointer Pin
ggoutam730-Nov-09 20:13
ggoutam730-Nov-09 20:13 
AnswerRe: Trim function for char pointer [modified] Pin
nenfa30-Nov-09 20:18
nenfa30-Nov-09 20:18 
AnswerRe: Trim function for char pointer Pin
tolw30-Nov-09 20:25
tolw30-Nov-09 20:25 
AnswerRe: Trim function for char pointer Pin
KingsGambit30-Nov-09 20:31
KingsGambit30-Nov-09 20:31 
GeneralRe: Trim function for char pointer Pin
ggoutam730-Nov-09 20:43
ggoutam730-Nov-09 20:43 
AnswerRe: Trim function for char pointer Pin
Richard MacCutchan30-Nov-09 22:30
mveRichard MacCutchan30-Nov-09 22:30 
GeneralRe: Trim function for char pointer Pin
ggoutam76-Dec-09 23:15
ggoutam76-Dec-09 23:15 
GeneralRe: Trim function for char pointer Pin
Richard MacCutchan7-Dec-09 5:11
mveRichard MacCutchan7-Dec-09 5:11 
QuestionThreading in C. What is the use of HANDLE in the following code? Pin
Razanust30-Nov-09 16:53
Razanust30-Nov-09 16:53 
QuestionRe: Threading in C. What is the use of HANDLE in the following code? Pin
«_Superman_»30-Nov-09 17:34
professional«_Superman_»30-Nov-09 17:34 
AnswerRe: Threading in C. What is the use of HANDLE in the following code? Pin
KingsGambit30-Nov-09 17:53
KingsGambit30-Nov-09 17:53 
Questionhow to make some area invisible Pin
lyp206030-Nov-09 15:26
lyp206030-Nov-09 15:26 
AnswerRe: how to make some area invisible Pin
«_Superman_»30-Nov-09 15:50
professional«_Superman_»30-Nov-09 15:50 
AnswerRe: how to make some area invisible Pin
loyal ginger30-Nov-09 15:51
loyal ginger30-Nov-09 15:51 
AnswerRe: how to make some area invisible Pin
Garth J Lancaster30-Nov-09 15:51
professionalGarth J Lancaster30-Nov-09 15:51 
GeneralRe: how to make some area invisible Pin
lyp206030-Nov-09 22:52
lyp206030-Nov-09 22:52 

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.