thomas_naveen 105 Junior Poster

Please remove this ";" at the end of the for loop in print_clauses.

for (i = 0; i < 18; ++i);
thomas_naveen 105 Junior Poster

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?

thomas_naveen 105 Junior Poster

Do you and "omgaga" go to the same school?

Same thing was posted some days back as well.

thomas_naveen 105 Junior Poster

The first thing that is wrong with your code is that you have not used code tags while posting.

thomas_naveen 105 Junior Poster

Mark the thread as solved, if your issue is resolved.

thomas_naveen 105 Junior Poster

Kindly use code tags or you will not get much help from here.

}while(AreThereMore);

The above line needs to be

}while(AreThereMore());
Salem commented: Would have been better if you'd stopped at the "use code tags" ;) +20
thomas_naveen 105 Junior Poster

Why don't you answer your questions with what you think is the right answer and why?

Ancient Dragon commented: Yes. +27
thomas_naveen 105 Junior Poster

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.

thomas_naveen 105 Junior Poster

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)

thomas_naveen 105 Junior Poster
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.

jephthah commented: doh! look at how many "veteran posters" missed that! good catch :) +6
jonsca commented: Yes, excellent job +3
thomas_naveen 105 Junior Poster

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.

thomas_naveen 105 Junior Poster
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.

thomas_naveen 105 Junior Poster

fmaxf for floats.

thomas_naveen 105 Junior Poster

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

thomas_naveen 105 Junior Poster

Better check out line 98 as well. It looks very similar to the bug you have identified.

Salem commented: It's the catch of the day :) +19
thomas_naveen 105 Junior Poster

I have seen this problem before of large arrays on stack.

Just declare it as a global.

halluc1nati0n commented: I didn't even think of the stack! +1
thomas_naveen 105 Junior Poster

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.

Ancient Dragon commented: Yes. +26
thomas_naveen 105 Junior Poster

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.

thomas_naveen 105 Junior Poster

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.

mmgoicochea commented: thanks for the help. I didnt realize the error until you told me lol then i was like oh yea I remember the teacher said not to forget about it hehe hehe +0
thomas_naveen 105 Junior Poster

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.

kylcrow commented: You deserve a rep bump +3
thomas_naveen 105 Junior Poster

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.

thomas_naveen 105 Junior Poster

use

yOn = scn.next();

instead of

yOn = scn.nextLine();

at 196

thomas_naveen 105 Junior Poster

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++;


}
thomas_naveen 105 Junior Poster

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=");
thomas_naveen 105 Junior Poster

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.