Re: [algogeeks] What is the error in the following function

2011-02-22 Thread Terence
Variable start and hex_buf point to string constant, which can not be modified. Change: char *start = "12.12.12.12.12976665176069214"; char *hex_buf = "65003a0a"; to: char start[] = "12.12.12.12.12976665176069214"; char hex_buf[] = "65003a0a"; On 2011-2-15 15:01, dinesh bansa

Re: [algogeeks] What is the error in the following function

2011-02-15 Thread dinesh bansal
got it clear.. thanks guys. On Tue, Feb 15, 2011 at 1:46 PM, jagannath prasad das wrote: > here start is pointing to string constant which is created in read-only > memory which can't be changed.so modifying it in the for loop causes > segmentation fault > declare it as a array type > > > On Tue,

Re: [algogeeks] What is the error in the following function

2011-02-15 Thread jagannath prasad das
here start is pointing to string constant which is created in read-only memory which can't be changed.so modifying it in the for loop causes segmentation fault declare it as a array type On Tue, Feb 15, 2011 at 12:36 PM, rahul wrote: > char *start is const char *start, pointer to const char, u c

Re: [algogeeks] What is the error in the following function

2011-02-14 Thread rahul
char *start is const char *start, pointer to const char, u can't derefernce it and change it. take a char start[256].try this. On Tue, Feb 15, 2011 at 12:31 PM, dinesh bansal wrote: > Hi All, > > Can you please point me to the error in the following function. It gives > segmentation fault. > > i

[algogeeks] What is the error in the following function

2011-02-14 Thread dinesh bansal
Hi All, Can you please point me to the error in the following function. It gives segmentation fault. int main() { char *start = "12.12.12.12.12976665176069214"; char *hex_buf = "65003a0a"; unsigned short i, j = 0; int new_len2 = strlen(hex_buf); for (i = 0; ((j+1) < new_len2);