tags:

views:

126

answers:

5

while(*a++ = *b++){} where a and b are valid char pointers.

+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
+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
I think this is most likely.
CiscoIPPhone
+1  A: 

It looks like memory allocated for array 'a' is less than the length of the array 'b'.

Naveen
+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
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