![]() |
|
#1
|
|||
|
|||
Employee program segmentation error.Hi, I'm having trouble with this C++ homework assignment. The program is supposed to read from three files. The first file contains the employee information to save in a struct (first, last name, ID number, job status,pay rate, hours worked). The first part adds the information into a struct array, and prints it out alphabetically (this part works). The second part is supposed read a file with the ID number of the employee and changes to the employee's information. There are two command codes S (job status) and P (payrate) (I get a segmentation fault when I return the search), and the 3rd part is supposed to calculate the hours worked (I haven't gotten there yet).
Here is the second part of my program working is the employee array, n is the number of employees added to the array. CPP / C++ / C Code:
Thanks for the help. |
|||
|
#2
|
|||
|
|||
Re: Employee program segmentation error.CPP / C++ / C Code:
Segmentation faults are typically caused by attempting to access memory that doesn't belong to a program. For example, accessing an element beyond the bounds of an array. Since nothing in your main() program gives a value to i, accessing array elements with index i results in undefined behavior, which could result in a segmentation error. (And even if it didn't crash, it couldn't possibly do anything useful with i, since its value is never defined in main() is never defined.) Regards, Dave |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 11:13 |
| Linked Lists advice request | promsan | C Programming Language | 74 | 23-May-2007 09:29 |
| Major newbie problem | cynack | MS Visual C++ / MFC Forum | 1 | 08-Apr-2007 12:25 |
| Help with syntax errors | PeteGallo | C Programming Language | 7 | 08-Aug-2005 21:30 |
| What is "Ambigious symbol" ??*( a compilation error) | small_ticket | C++ Forum | 2 | 07-Jan-2005 22:10 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The