Click here to Skip to main content
15,915,603 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow do I stop a process before it completes? Pin
smoothchew14-Jun-02 13:55
smoothchew14-Jun-02 13:55 
AnswerRe: How do I stop a process before it completes? Pin
Paul M Watt14-Jun-02 17:00
mentorPaul M Watt14-Jun-02 17:00 
QuestionWhy did I get this "file corrupt or missing" error? Pin
Selevercin14-Jun-02 12:58
Selevercin14-Jun-02 12:58 
AnswerRe: Why did I get this "file corrupt or missing" error? Pin
14-Jun-02 13:01
suss14-Jun-02 13:01 
AnswerRe: Why did I get this "file corrupt or missing" error? Pin
Nish Nishant14-Jun-02 15:27
sitebuilderNish Nishant14-Jun-02 15:27 
GeneralRe: Why did I get this "file corrupt or missing" error? Pin
Selevercin15-Jun-02 14:26
Selevercin15-Jun-02 14:26 
GeneralEnable Controls Pin
14-Jun-02 11:14
suss14-Jun-02 11:14 
GeneralStrange unhandled exception. Pin
redeemer14-Jun-02 10:57
redeemer14-Jun-02 10:57 
I have made a function to replace every occurence of a substring in a string with a new string. But if i put it in another function, then when that other function is done, an unhandled exception error appears. It's not my function performing an unhandled exception, it's the other function that does it when it's done, but only if i use the stringreplace function in that function:

Unhandled exception in app.exe: 0xC0000005: Access Violation.

here's the function:
void ReplaceString(char *target, const char *toreplace, const char *replacewith)
{
	if ((!strcmp(target, "")) || (!strcmp(toreplace, "")) || (!strcmp(replacewith, "")))
		return;
		
	char *pos = strstr(target, toreplace);
	int currentpos = pos-target;
	char *after = new char[strlen(target)-1];

	while (pos)
	{
	currentpos = pos-target;
	strcpy(after, pos+strlen(toreplace));

	strcpy(&target[currentpos], replacewith);
	strcat(target, after);
	pos = strstr(&target[currentpos+strlen(replacewith)], toreplace);
	}

	delete after;
}


Thanks in advance.
GeneralRe: Strange unhandled exception. Pin
14-Jun-02 11:26
suss14-Jun-02 11:26 
GeneralRe: Strange unhandled exception. Pin
Mike Nordell14-Jun-02 11:27
Mike Nordell14-Jun-02 11:27 
GeneralRe: Strange unhandled exception. Pin
Tim Smith14-Jun-02 11:36
Tim Smith14-Jun-02 11:36 
GeneralRe: Strange unhandled exception. Pin
redeemer14-Jun-02 12:05
redeemer14-Jun-02 12:05 
GeneralRe: Strange unhandled exception. Pin
Tim Smith14-Jun-02 17:23
Tim Smith14-Jun-02 17:23 
GeneralRe: Strange unhandled exception. Pin
Matt Gullett14-Jun-02 16:52
Matt Gullett14-Jun-02 16:52 
GeneralRe: Strange unhandled exception. Pin
Tim Smith14-Jun-02 17:23
Tim Smith14-Jun-02 17:23 
GeneralHelp - Scrollbars are gone! Pin
14-Jun-02 10:35
suss14-Jun-02 10:35 
GeneralProgrammatically Run a Remote Process Pin
Chad Koehler14-Jun-02 9:29
Chad Koehler14-Jun-02 9:29 
GeneralRe: Programmatically Run a Remote Process Pin
Jason Henderson14-Jun-02 16:44
Jason Henderson14-Jun-02 16:44 
GeneralIs there a function for replacing substrings inside a string with a new string? (non-MFC) Pin
redeemer14-Jun-02 8:42
redeemer14-Jun-02 8:42 
GeneralRe: Is there a function for replacing substrings inside a string with a new string? Pin
Jason Henderson14-Jun-02 8:42
Jason Henderson14-Jun-02 8:42 
GeneralRe: Is there a function for replacing substrings inside a string with a new string? Pin
Chris Losinger14-Jun-02 8:50
professionalChris Losinger14-Jun-02 8:50 
GeneralGetting the location of a specific systray icon Pin
David Wulff14-Jun-02 8:40
David Wulff14-Jun-02 8:40 
GeneralAutomating VB COM Dll from ATL C++ Pin
14-Jun-02 8:28
suss14-Jun-02 8:28 
GeneralRe: Automating VB COM Dll from ATL C++ Pin
Paul M Watt14-Jun-02 17:09
mentorPaul M Watt14-Jun-02 17:09 
GeneralRe: Automating VB COM Dll from ATL C++ Pin
17-Jun-02 8:38
suss17-Jun-02 8:38 

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.