Randi Botse wrote: > Thanks Glynn for let me know that the void* pointer arithmetic is > undefined, and gcc automatically cast it to char* pointer... is this > because void* doesn't have a size? Technically, it's because the standard says that it's undefined. Pointer arithmetic is defined in terms of pointers to array elements, e.g. if you have: int foo[N]; int *p = &foo[A]; int *q = p+B; int *r = &foo[A+B]; then r==q. But you can't have an array of "void", so pointer arithmetic on void* isn't meaningful. > im curious when i do sizeof(void*), > my machine tell me sizeof(void*) is 4kb... i thnk when i do (void* + > 1) that's means "4 kb after void*"?.... The result of sizeof is in bytes (technically, "char"s; sizeof(char) is guaranteed to be 1). The result of "sizeof" applied to any pointer type will typically be 4 bytes on 32-bit systems or 8 bytes on 64-bit systems. Although it's possible for pointers to different types to have different sizes, it's rare. > i run the code in GNOME terminal, that's means stdout connected to xterm? No, to Gnome terminal; xterm is similar. It's possible that the behaviour which you experience is a property of the terminal emulator. You might try running the program on a different terminal emulator, or on a VT, to see if the same problem occurs there. -- Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html