Hi guys,
I've got problem with my little C program. Maybe you could help me.
char* shiftujVzorku(char* text, char* pattern, int offset){
char* pom = text;
int size = 0;
int index = 0;
while(*(text + size) != '\0'){
size++;
}
while(*(pom + index) != '\0'){
if(overVzorku(pom + index, pattern)){
while(*pattern != '\0'){
//vyment *pom s *pom + offset
if(pom + index + offset < text + size){
char x = *(pom + index + offset);
char y = *(pom + index);
int adresa = *(pom + index + offset);
*(pom + index + offset) = y; // SEGMENTATION FAULT
*(pom + index) = x;
//*pom = *pom - *(pom + offset);
//*(pom + offset) = *(pom + offset) + *pom;
//*pom = *(pom + offset) - *pom;
}
else{
*pom = *pom - *(pom + offset - size);
*(pom + offset - size) = *(pom + offset - size) + *pom;
*pom = *(pom + offset - size) - *pom;
}
pattern++;
}
break;
}
index++;
}
return text;
}
Isn't important what's the programm doing. Maybe there's lot of bugs. But, why do I get SEGMENTATION FAULT (for destination see code) at this line? I'm, trying to write some char value to memory space, with help of address "pom + offset + index". Thanks for everything helpful. :)