when i run the code,, it shows:
*** glibc detected *** ./c1a: munmap_chunk(): invalid pointer: 0x00000000146fe250 ***
======= Backtrace: =========
/lib64/libc.so.6(cfree+0x166)[0x3ca5071486]
./c1a[0x40267f]
./c1a[0x4026b1]
./c1a[0x402e23]
./c1a[0x402eec]
./c1a[0x40155a]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x3ca501d994]
./c1a(__gxx_personality_v0+0x81)[0x400c99]
======= Memory map: ========
00400000-00404000 r-xp 00000000 78:01 3548933067 /home/gfs/cnets/research/rw36/0504-toy/0725Vari/c++/1a/c1a
00604000-00605000 rw-p 00004000 78:01 3548933067 /home/gfs/cnets/research/rw36/0504-toy/0725Vari/c++/1a/c1a
146f3000-14714000 rw-p 146f3000 00:00 0 [heap]
3ca4c00000-3ca4c1c000 r-xp 00000000 08:02 13271346 /lib64/ld-2.5.so
3ca4e1c000-3ca4e1d000 r--p 0001c000 08:02 13271346 /lib64/ld-2.5.so
3ca4e1d000-3ca4e1e000 rw-p 0001d000 08:02 13271346 /lib64/ld-2.5.so
3ca5000000-3ca514d000 r-xp 00000000 08:02 13271403 /lib64/libc-2.5.so
3ca514d000-3ca534d000 ---p 0014d000 08:02 13271403 /lib64/libc-2.5.so
3ca534d000-3ca5351000 r--p 0014d000 08:02 13271403 /lib64/libc-2.5.so
3ca5351000-3ca5352000 rw-p 00151000 08:02 13271403 /lib64/libc-2.5.so
3ca5352000-3ca5357000 rw-p 3ca5352000 00:00 0
3ca5800000-3ca5882000 r-xp 00000000 08:02 13271721 /lib64/libm-2.5.so
3ca5882000-3ca5a81000 ---p 00082000 08:02 13271721 /lib64/libm-2.5.so
3ca5a81000-3ca5a82000 r--p 00081000 08:02 13271721 /lib64/libm-2.5.so
3ca5a82000-3ca5a83000 rw-p 00082000 08:02 13271721 /lib64/libm-2.5.so
3ca7800000-3ca780d000 r-xp 00000000 08:02 13272007 /lib64/libgcc_s-4.1.2-20080825.so.1
3ca780d000-3ca7a0d000 ---p 0000d000 08:02 13272007 /lib64/libgcc_s-4.1.2-20080825.so.1
3ca7a0d000-3ca7a0e000 rw-p 0000d000 08:02 13272007 /lib64/libgcc_s-4.1.2-20080825.so.1
3ca8c00000-3ca8ce6000 r-xp 00000000 08:02 11075952 /usr/lib64/libstdc++.so.6.0.8
3ca8ce6000-3ca8ee5000 ---p 000e6000 08:02 11075952 /usr/lib64/libstdc++.so.6.0.8
3ca8ee5000-3ca8eeb000 r--p 000e5000 08:02 11075952 /usr/lib64/libstdc++.so.6.0.8
3ca8eeb000-3ca8eee000 rw-p 000eb000 08:02 11075952 /usr/lib64/libstdc++.so.6.0.8
3ca8eee000-3ca8f00000 rw-p 3ca8eee000 00:00 0
2b4be3f0c000-2b4be3f0f000 rw-p 2b4be3f0c000 00:00 0
2b4be3f58000-2b4be3f5a000 rw-p 2b4be3f58000 00:00 0
7fff77e71000-7fff77e86000 rw-p 7ffffffe9000 00:00 0 [stack]
7fff77ea1000-7fff77ea4000 r-xp 7fff77ea1000 00:00 0 [vdso]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vsyscall]
Aborted
what's the problem ??
You're trying to free memory using a pointer that doesn't match one that was given when the memory was handed out (using malloc).
Build it with debugging symbols on, and then run it again under gdb or valgrind.