Stop for a minute and think Donnie. If I told you I wrote a program
(but did not tell you what the program was, did not post any code)
and said I was getting a "parse error", could you tell me what
my specific error was?
Now, generally, one can guess when one sees a segmentation fault,
these are usually the result of some form of memory error, something
like a pointer error, or an array out of bounds condition.
If you are trying to do some kind of file operations, which your
subject line implies, then one might surmise you are trying to
open a file that might not be there, or are doing something with
the file pointer when the file is closed.
These are guesses....
When you just post an error message, and ask what's wrong, it's
just one step removed from posting "Help, my code won't work, what's
wrong" and thinking an answer is a reasonable expectation.
Time taken with things like the Basic 3, describinbg what you are
trying to do, and what is happening really saves time. It also
shows respect for those complete strangers that you are asking to
help you for free.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
An "access violation" is a run-time error. Given that this code will not compile, this cannot be the code you are running.
Line 248:
> add_node(char game[50], char genre[20]);
That is not a valid function call. If I change that to:
> add_node(game, genre);
I then get:
sandbox.cpp(392) : warning C4100: 'previous_ptr' : unreferenced formal parameter
sandbox.cpp(233) : error C4716: 'pos_insert_point' : must return a value
sandbox.cpp(390) : error C4716: 'ready' : must return a value
sandbox.cpp(453) : error C4716: 'handle' : must return a value
Although these are VC++ messages, I have no reason to believe that it is any more compilable in GCC.
The thing is we could wade through all that code to try to find the error, but that is unlikely to be productive, in that amount of code it is likely that we'll find a number of flaws, which may or may not be related to your problem. So the obvious solution is to compile it, run it , reproduce your error, and debug it. However this is not the same code as that which you are running, so even that might be pointless, even if we could compile it. And the code is interactive and has a number of possible execution paths, unless you also provide a test case with specific steps to reproduce the error, you are still making unnecessarily hard. It also required a data file, so and example or definition of its content and format would be necessary.
Of course you could also use the debugger to investigate the problem yourself. which is exactly what I would do if I could. If you choose to use the abysmal Dev-C++ debugger, good luck.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Interestingly, here is what I get when I compile it OOB with GCC-4.3.2 under MinGW
g++ testit66.cpp
testit66.cpp: In function 'void get_info(char, char)':
testit66.cpp:284: error: expected primary-expression before 'char'
testit66.cpp:284: error: expected primary-expression before 'char'
which is the same error to which you referred Clifford.
When I fix it as you did, it does compile.
Interesting
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
well i went to school and i got the code to do what i want it to do but at home it wont work but thank you for both your advices, it was a high schoolers mistake. take a look at get_info its suppose to be a int get_info not a void and with some changing of that and it would work as a link list like i wanted it to... also the add_node i had figured out right after i posted it so i was feeling like an idiot after i posted it.. at least thats what i did at my school but all in all the only thing is i just didnt know what the "An Access Violation (Segmentation Fault) raised in your program" was talking about and i didnt know what to do
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> i just didnt know what the "An Access Violation (Segmentation Fault) raised in your program" was talking about and i didnt know what to do
Typically when you run code in a debugger, and an access violation occurs, it will break at the point in the code the violation occurred, and you can inspect the variables and stack etc.
What it means is that there was an attempt to access a memory location not within your process's control. Usually a bad pointer or a buffer overrun. Unfortunately the point at which teh program crashes and the root cause need not be in the same location, so you need to be a bit forensic or just lucky in your debug activity.
Another problem you may encounter is the code runs in one environment and not in another, since the behaviour of such bugs is non-deterministic. This means for example that code that breaks when run directly works in the debugger and vice-versa, or it works on one machine and not another. I mention this because you may find that your 'working' code is in fact still flawed, since you say it works at school, but not at home.
Careful coding practices can help. For linked lists you have to have a really good reason not to use the standard <list> class template.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
this is the error that this gives me
An Access Violation (Segmentation Fault) raised in your program
Divert your warp engine power to the shields.
Want a better answer, ask a better question. This is probably the worst one I have seen in a long time.
Do you really expect to just post an error message and get an answer? Withoout us knowing ONE thing about the code?
Post your Basic 3!
Wayne
That's nice for you. It means you code contains an error. What more can we say!?
Stop for a minute and think Donnie. If I told you I wrote a program
(but did not tell you what the program was, did not post any code)
and said I was getting a "parse error", could you tell me what
my specific error was?
Now, generally, one can guess when one sees a segmentation fault,
these are usually the result of some form of memory error, something
like a pointer error, or an array out of bounds condition.
If you are trying to do some kind of file operations, which your
subject line implies, then one might surmise you are trying to
open a file that might not be there, or are doing something with
the file pointer when the file is closed.
These are guesses....
When you just post an error message, and ask what's wrong, it's
just one step removed from posting "Help, my code won't work, what's
wrong" and thinking an answer is a reasonable expectation.
Time taken with things like the Basic 3, describinbg what you are
trying to do, and what is happening really saves time. It also
shows respect for those complete strangers that you are asking to
help you for free.
Wayne
include <iostream>
include <string>
include <iomanip>
include <fstream>
include <windows.h>
using namespace std;
//functions
void get_info(char game[50] , char genre[20]);
void display();
void delete_L();
void add_node(char game[50] , char genre[20]);
void move_to_end();
void find();
char Gamers[50];
void delete_node();
Genres head_ptr;
Genres current_ptr;
Genres new_ptr;
Genres temp_ptr;
Genres previous_ptr;
Genres before_ptr;
Genres after_ptr;
void search();
int ready();
void delete_node(Genres previous_ptr);
char genre[20];
void find();
void delete_head();
char game[50];
void delete_mid();
void delete_end();
int handle(int number);
int edit(char game[50] , char genre[20]);
void write_list_to_file();
void load_list_from_file();
void insert_node(Genres new_rec_ptr);
void make_node_new_head(Genres new_rec_ptr);
void add_node_to_end(Genres new_rec_ptr);
Genres pos_insert_point(char Gamers[50]);
int main()//main is the main part of the program
{
void write_list_to_file()
{
ofstream outfile;
outfile.open("GAMES.DAT", ios::out);
void load_list_from_file()
{
Genres *new_rec_ptr;
ifstream infile;
int end = 0;
char temp[50], temp2[20];
}
/
void make_node_new_head(Genres new_rec_ptr)
{
Genres *temp_ptr;
temp_ptr = head_ptr;
head_ptr = new_rec_ptr;
}
sorry for being a punk about all this im just been working on it for school...
An "access violation" is a run-time error. Given that this code will not compile, this cannot be the code you are running.
Line 248:
> add_node(char game[50], char genre[20]);
That is not a valid function call. If I change that to:
> add_node(game, genre);
I then get:
sandbox.cpp(392) : warning C4100: 'previous_ptr' : unreferenced formal parameter
sandbox.cpp(233) : error C4716: 'pos_insert_point' : must return a value
sandbox.cpp(390) : error C4716: 'ready' : must return a value
sandbox.cpp(453) : error C4716: 'handle' : must return a value
Although these are VC++ messages, I have no reason to believe that it is any more compilable in GCC.
The thing is we could wade through all that code to try to find the error, but that is unlikely to be productive, in that amount of code it is likely that we'll find a number of flaws, which may or may not be related to your problem. So the obvious solution is to compile it, run it , reproduce your error, and debug it. However this is not the same code as that which you are running, so even that might be pointless, even if we could compile it. And the code is interactive and has a number of possible execution paths, unless you also provide a test case with specific steps to reproduce the error, you are still making unnecessarily hard. It also required a data file, so and example or definition of its content and format would be necessary.
Of course you could also use the debugger to investigate the problem yourself. which is exactly what I would do if I could. If you choose to use the abysmal Dev-C++ debugger, good luck.
Clifford
Interestingly, here is what I get when I compile it OOB with GCC-4.3.2 under MinGW
g++ testit66.cpp
testit66.cpp: In function 'void get_info(char, char)':
testit66.cpp:284: error: expected primary-expression before 'char'
testit66.cpp:284: error: expected primary-expression before 'char'
which is the same error to which you referred Clifford.
When I fix it as you did, it does compile.
Interesting
well i went to school and i got the code to do what i want it to do but at home it wont work but thank you for both your advices, it was a high schoolers mistake. take a look at get_info its suppose to be a int get_info not a void and with some changing of that and it would work as a link list like i wanted it to... also the add_node i had figured out right after i posted it so i was feeling like an idiot after i posted it.. at least thats what i did at my school but all in all the only thing is i just didnt know what the "An Access Violation (Segmentation Fault) raised in your program" was talking about and i didnt know what to do
> i just didnt know what the "An Access Violation (Segmentation Fault) raised in your program" was talking about and i didnt know what to do
Typically when you run code in a debugger, and an access violation occurs, it will break at the point in the code the violation occurred, and you can inspect the variables and stack etc.
What it means is that there was an attempt to access a memory location not within your process's control. Usually a bad pointer or a buffer overrun. Unfortunately the point at which teh program crashes and the root cause need not be in the same location, so you need to be a bit forensic or just lucky in your debug activity.
Another problem you may encounter is the code runs in one environment and not in another, since the behaviour of such bugs is non-deterministic. This means for example that code that breaks when run directly works in the debugger and vice-versa, or it works on one machine and not another. I mention this because you may find that your 'working' code is in fact still flawed, since you say it works at school, but not at home.
Careful coding practices can help. For linked lists you have to have a really good reason not to use the standard <list> class template.
Clifford