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]

Re: 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?
> 	char *text="This is the sentence from here";
> 	char *find="from";
> 	char *replace_with="to";

I'm not an expert, but compiler puts "This is the sentence from here"
into read only memory and then you are trying to modify it, so your OS
terminates your program, it is not allowed to modify read only memory
So the quick fix:
char text[sizeof("This is the sentence from here")];
strcpy(text, "This is the sentence from here");
char *find="from";
...
Arturas M.


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