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 bansal wrote:
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); i+=2,j+=2)
{
start[i] = hex_buf[j];
start[i+1] = hex_buf[j+1];
}
}
Thanks,
--
Dinesh Bansal
The Law of Win says, "Let's not do it your way or my way; let's do it
the best way."
--
You received this message because you are subscribed to the Google
Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
You received this message because you are subscribed to the Google Groups "Algorithm
Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.