Please remove this ";" at the end of the for loop in print_clauses.
for (i = 0; i < 18; ++i);
Please remove this ";" at the end of the for loop in print_clauses.
for (i = 0; i < 18; ++i);
Please check the following.
1) Your file "max2sat_data" is present in the current directory with read permissions.
2) What is build_clauses returning? Is memory allocated to clauses when you are calling print_clauses?
Do you and "omgaga" go to the same school?
Same thing was posted some days back as well.
The first thing that is wrong with your code is that you have not used code tags while posting.
Mark the thread as solved, if your issue is resolved.
Kindly use code tags or you will not get much help from here.
}while(AreThereMore);
The above line needs to be
}while(AreThereMore());
Why don't you answer your questions with what you think is the right answer and why?
Your project must also include three separate files: a header file, an implementation file, and a driver/main file.
As mentioned in the problem statement, it is your project. So you should be doing it yourself and approaching us for any issues that you face in the project.
Try implementing it and post any issues that you face.
Move the brace at 54 to 45 and the code resolves into a main function and a print function.
Call the print function from the main to execute it. (print)
char letters[6];
int mem[3];
int i, j;
letters[0]=65;//A
letters[1]=66;//B
letters[2]=71;//G
letters[3]=77;//M
letters[4]=78;//N
letters[5]=82;//R
letters[6]=86;//V
You are accessing the array boundary here. Change 6 to 7 in the array declaration.
Memory should be allocated before you use the pointer for storing data.
In the current code you are taking in data to a pointer which could be pointing anywhere and then pointing that pointer to a fresh memory location.
You lose the input data in this way.
Make the 7th line your 5th line and check out the results.
void move_left();
void move_mid();
void move_right();
Put the three lines at the top of the file or in a header file, move.h
and say
#include "move.h"
at the top of the file
I am assuming that move_right is aslo visible for compilation.
fmax takes only two variables as input.
So you can only use fmax(a,b)
For three variables a,b,c
use something like
d = fmax(a,b);
e = fmax(c,d)
e will be the max of a,b,c
Better check out line 98 as well. It looks very similar to the bug you have identified.
I have seen this problem before of large arrays on stack.
Just declare it as a global.
Welcome to the club!!
However, it is fairly easy to identify SEG faults once you can competently use a debugger. Compile with -g option to use binary with debugger.
There are some cases where even the debugger can't help you.
Thorough analysis of the code only can help you there.
I wanted to check whether there is a naming conflict since the code has
using namespace std;
It could be something specific to the version that is being used.
The functions num and results have been defined initially with no arguments.
In function main, those functions are called with no arguments.
But, while implementing the functions, arguments are present.
The linker is trying to look for the functions called in main. Since it is not able to find the functions num() and results() with no arguments it is giving this error.
You could try running the code on gdb and see where it is segfaulting?
Could you post your entire code together so that it can be better viewed? Looking at it in bits and pieces is a difficult thing.
I believe the problem is due to the set used. It is trying to do an internal sort operation. You could try to fix the problem by overloading '<' operator for Node class.
use
yOn = scn.next();
instead of
yOn = scn.nextLine();
at 196
If you reach to this level of granularity then there is not much to do , is there?
Once you get the string starting with SRC, you can copy the required part of it to another string using a loop (your exit criteria would be the occurrance of the D of DST) or some standard copy function.
[EDIT]
char src[20];
int i = 0;
while(1)
{
if((src[i] == 'D') || (i >19))
{
break;
}
src[i] = result[i];
i++;
}
In the while loop that you are using for printing why don't you do an strstr and extract the value that you need?
Something like
strstr(result, "SRC=");
As Ancient Dragon has mentioned in his post, you should be using 'new' and 'delete' operators in C++.
malloc and free can be used in C.