Re: What this error code means?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux