c++ - Segmentation fault on writing char to char* address -


I have a problem with my small program that you can help me.

  char * shiftuj vzorku (char * text, char * pattern, int offset) {char * pom = text; Int size = 0; Int index = 0; While (* (text + size)! = '\ 0') {size ++; } (* (Palm + index)! = '\ 0') {if (overrun (pod + index, pattern)) {while (* pattern! = '\ 0') {// vyment * pom s * pom + Offset if (palm + index + offset & lt; text + size) {char x = * (palm + index + offset); Char y = * (palm + index); Int adresa = * (palm + index + offset); * (Palm + index + offset) = y; // signature fault * (palm + index) = x; // * palm = * palm - * (palm + offset); // * (palm + offset) = * (palm + offset) + palm; // * palm = * (palm + offset) - * palm; } And {* palm = * palm - * (palm + offset - size); * (Palm + offset - size) = * (palm + offset - size) + palm; * Palm = * (pom + offset - size) - * palm; } Pattern ++; }             break; } Index ++; } Return text; }  

Not important What the program is doing is probably a lot of bugs, but why do I get this segmentation fault (to see the destination) on this line? I'm trying to move something with the help of the "Palm + offset + index" address, for memory space. Thanks to everything useful :)

Do you have any chance of calling code like this From:

  childcare ("fobar", "xx", 0);  

If so, then your code is attempted to be written in the letter, which is illegal in C. You should do this:

  char buf [] = "foobar"; Infant Vocco (Buff, "XX", 0);  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -