This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

What this error code means?


Sir,
I`ve written the following C code(Program is in attachment) to find a substring from the given string and replace it with the given string. I compiled it in Turbo cpp it worked fine and i got the result.


When i used the same in GCC. It compiles successfully but while executing it gives the following result.
"Tool completed with exit code -1073741819"
What does this mean?
What do i have to do it run successfully?


Plz reply at the earliest..

Thank you,
K.Naga Priya


(Attachment has the C Program).


##############################################################################################################################################
The information transmitted is intended for the person or entity to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination, copying or other use of, or taking any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited. If you have received this in error, please contact the sender and delete
the material from your system. Accord Software & Systems Pvt. Ltd. (ACCORD) is not responsible for any changes made to the material other
than those made by ACCORD or for the effect of the changes on the meaning of the material.
##############################################################################################################################################
#include<stdio.h>
#include<string.h>


#define SUCCESS 1
#define FAILURE	-1
#define NOTFOUND 0
int FindAndReplace(char*,char*,char*);
int main()
{
	char *text="This is the sentence from here";
	char *find="from";
	char *replace_with="to";
	int ret_val=0;
/*	clrscr();*/
	ret_val=FindAndReplace(text,find,replace_with);
	printf("%s",text);
	return(ret_val);
}
int FindAndReplace(char *text,char *find,char *replace_with)
{
	char *ptr;
	char *tmp_index;
	char dest[1024];
	int length;
	int i=0;
	if((ptr=(char*)strstr(text,find))!=NULL)
	{
		if(strlen(text)-strlen(find)+strlen(replace_with)>=1024)
		{
			/*Buffer size not sufficient to perform the operation*/
			/*Return failure*/
			return(FAILURE);
		}
		else
		{	length=abs(((char*)text-(char*)ptr));
			tmp_index=text;
			for(i=0;i<length;i++)
			{
			       dest[i]= *(tmp_index++);
			}
			dest[i]='\0';
			strcat(dest,replace_with);
			length=strlen(find);
			ptr+=length;
			strcat(dest,ptr);
			strcpy(text,dest);
			return(SUCCESS);
		}
	}
	else
	{
		/*The substring is not found*/
		return(NOTFOUND);
	}
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]