while(*a++ = *b++){}
where a and b are valid char pointers.
views:
126answers:
5
+3
A:
The strings pointed to may not be null terminated meaning data is being read from and assigned to memory it should not have access to, hence the violation.
CiscoIPPhone
2009-07-16 11:57:16
+11
A:
If b is a 10 character null terminated string and a is a buffer where 4 chars has been allocated, you'll write outside of allocated memory using the above code.
Martin
2009-07-16 11:57:21
I think this is most likely.
CiscoIPPhone
2009-07-16 12:01:49
+1
A:
It looks like memory allocated for array 'a' is less than the length of the array 'b'.
Naveen
2009-07-16 12:01:39
+7
A:
One alternative answer:
char *a = "Hello";
char *b = "World";
These are both valid char pointers. But a does not point to writable memory.
Paul Mitchell
2009-07-16 12:05:41
A:
If you're running it on MSDev, bung it in the debugger and step through it, and/or have a look at the actual memory areas where a and b are stored and see directly what's going on. It could be any of the things already mentioned as possibilities.
Vicky
2009-07-16 12:19:43