1. Engineering
  2. Computer Science
  3. c language please tell me how to fix this error...

Question: c language please tell me how to fix this error...

Question details

C language. Please tell me how to fix this error.

flip1 ~/CS261/hw/assign1 250% ./test

== Here are the results of init_student():
Name: Luke Skywalker, ID: 933111111, , GPA: 3.750000

== Here's that student (left) and its deep copy (right):
name (value): Luke Skywalker Luke Skywalker
name (pointer): 0xb93010 0xb93010
id: 933111111 933111111
gpa: 3.750000 3.750000

== Here are the results of create_student_array():
Name: Luke Skywalker, ID: 933111111, , GPA: 3.750000
Name: Princes Leia, ID: 933222222, , GPA: 4.000000
Name: Chewbacca, ID: 933333333, , GPA: 3.000000
Name: Han Solo, ID: 933444444, , GPA: 2.500000
Name: Lando Calrissian, ID: 933555555, , GPA: 3.670000
Name: Darth Vader, ID: 933666666, , GPA: 1.330000
Name: C-3PO, ID: 933777777, , GPA: 3.250000
Name: R2-D2, ID: 933888888, , GPA: 3.900000

== Here's the student with the highest GPA:
Name: Princes Leia, ID: 933222222, , GPA: 4.000000

== Here's the student with the lowest GPA:
Name: Darth Vader, ID: 933666666, , GPA: 1.330000

== Here are the students ordered by decreasing GPA:
Name: Luke Skywalker, ID: 933111111, , GPA: 4.000000
Name: Princes Leia, ID: 933222222, , GPA: 3.900000
Name: Chewbacca, ID: 933333333, , GPA: 3.750000
Name: Han Solo, ID: 933444444, , GPA: 3.670000
Name: Lando Calrissian, ID: 933555555, , GPA: 3.250000
Name: Darth Vader, ID: 933666666, , GPA: 3.000000
Name: C-3PO, ID: 933777777, , GPA: 2.500000
Name: R2-D2, ID: 933888888, , GPA: 1.330000
*** Error in `./test': double free or corruption (fasttop): 0x0000000000b93010 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x81499)[0x7f83ebd09499]
./test[0x40090c]
./test[0x400859]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f83ebcaa445]
./test[0x4005b9]
======= Memory map: ========
00400000-00402000 r-xp 00000000 00:33 2433045595 /nfs/stak/users/abbasd/CS261/hw/assign1/test
00601000-00602000 r--p 00001000 00:33 2433045595 /nfs/stak/users/abbasd/CS261/hw/assign1/test
00602000-00603000 rw-p 00002000 00:33 2433045595 /nfs/stak/users/abbasd/CS261/hw/assign1/test
00b93000-00bb4000 rw-p 00000000 00:00 0 [heap]
7f83e4000000-7f83e4021000 rw-p 00000000 00:00 0
7f83e4021000-7f83e8000000 ---p 00000000 00:00 0
7f83eba72000-7f83eba87000 r-xp 00000000 fd:02 18083679 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f83eba87000-7f83ebc86000 ---p 00015000 fd:02 18083679 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f83ebc86000-7f83ebc87000 r--p 00014000 fd:02 18083679 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f83ebc87000-7f83ebc88000 rw-p 00015000 fd:02 18083679 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f83ebc88000-7f83ebe4b000 r-xp 00000000 fd:02 16811455 /usr/lib64/libc-2.17.so
7f83ebe4b000-7f83ec04a000 ---p 001c3000 fd:02 16811455 /usr/lib64/libc-2.17.so
7f83ec04a000-7f83ec04e000 r--p 001c2000 fd:02 16811455 /usr/lib64/libc-2.17.so
7f83ec04e000-7f83ec050000 rw-p 001c6000 fd:02 16811455 /usr/lib64/libc-2.17.so
7f83ec050000-7f83ec055000 rw-p 00000000 00:00 0
7f83ec055000-7f83ec077000 r-xp 00000000 fd:02 18217608 /usr/lib64/ld-2.17.so
7f83ec239000-7f83ec23c000 rw-p 00000000 00:00 0
7f83ec273000-7f83ec276000 rw-p 00000000 00:00 0
7f83ec276000-7f83ec277000 r--p 00021000 fd:02 18217608 /usr/lib64/ld-2.17.so
7f83ec277000-7f83ec278000 rw-p 00022000 fd:02 18217608 /usr/lib64/ld-2.17.so
7f83ec278000-7f83ec279000 rw-p 00000000 00:00 0
7ffc8a202000-7ffc8a223000 rw-p 00000000 00:00 0 [stack]
7ffc8a36e000-7ffc8a370000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Abort (core dumped)
flip1 ~/CS261/hw/assign1 251%

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution