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

OK so what, I guess, is the new added node here in my code then? I thought that the statement:

curNode = curNode->next;

moved the pointer to the next placeholder, ready to store a new value. Am I missing something here?

@thomas_naveen
I implemented the changes you suggested. You can see the new code down below. I changed the struct to a class (made everything public for now, just for simplicity for the time being). I understand the need to change to **curNode in the function call, so I have a pointer to my pointer. That makes sense to me. What I don't understand now is why it has effectively changed nothing in my end result. Still just getting 1 and 9 in my output.

Sorry for being dim, I'm new to this and for some reason ListNodes just seem very abstract to me. Thanks for your help.

#include <iostream>

using namespace std;



class ListNode {

public:

  double value;

  ListNode *next;

  void add( double, ListNode** );

  bool isMember( double );

};



void ListNode::add( double x, ListNode **curNode ) {

	(*curNode)->next = new ListNode;  // Creates a ListNode at the end of the list

	(*curNode) = (*curNode)->next; // Points to that ListNode

	(*curNode)->next = 0;         // Prevents it from going any further

	(*curNode)->value = x;

	//cout << (*curNode)->value << endl;

}



int main() {



	const int SIZE = 5;

	double testValue[SIZE] = { 1, 3, 5, 7, 9 };

	double* tv = testValue;



	ListNode *head;       

	ListNode *curNode;  



	

	head = new ListNode; …
thomas_naveen 105 Junior Poster

Use the following function

void ListNode::add( double x, ListNode **curNode )

use

(*curNode)

in the above function wherever you are using curNode


Use

curNode->add( *( tv + i ), &curNode );

at line 40.

Use

curNode = head;

at line 42 to reinitialize your curNode to the head pointer.

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

try putting the proper prototype at line 22.

thomas_naveen 105 Junior Poster

The code is doing exactly what you have asked it to do.

Your for loop on line 33 is the culprit.

Remove the for loop and use

answer += values[sumnumber][columns];

on line 37. (retain the inner loop)

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

Can you use something like strstr?

thomas_naveen 105 Junior Poster

What is the data type of address?

Will the required data be always at the same index of address?

thomas_naveen 105 Junior Poster

try #define

thomas_naveen 105 Junior Poster

Instead of iterating over the string, you should be iterating over the array. Replace < str.length() with < arraySize2

Otherwise you are looking for only A & B.

Also follow AD's point of multiple declaration.

thomas_naveen 105 Junior Poster

Your code does not compile.

To solve your problem, remove the else part which returns 1.

Add a initialised (true) flag in the function. Whenever an alphabet is encountered wich does not match your two conditions , set the value of the flag to a new value (false).

After the entire string is checked, use the flag to return 1 or some other value.

thomas_naveen 105 Junior Poster

728,729,730,731 requires [TEX];[/TEX] to end the lines.

Hope this fixes your problem.

I am giving this help because it immediately stood out in a compiler.

If you want more help, indent your code properly.

thomas_naveen 105 Junior Poster

As the code stands it is not displaying anything on the screen, right?

You need to add the file reading part , display to screen part and a proper exit criteria inside the while loop to get it to work.

thomas_naveen 105 Junior Poster
while (!file.eof())
   {
       if(count==24)
    system("pause");
          count=0;

   }

Looks like it is running an infinite loop.

Why should the EOF be reached? Also checking for EOF is not such a great practice.

thomas_naveen 105 Junior Poster

You forgot to put [TEX]()[/TEX] after Africa.

thomas_naveen 105 Junior Poster

I cannot help you if you refuse to indent your code.

Also, if you indent your code properly you might find out what is wrong by yourself.

thomas_naveen 105 Junior Poster

unnecessary opening brace at line 39?

thomas_naveen 105 Junior Poster

Lack of indentation makes this code impossible to read.

It looks very much like you have one closing brace too many before the first error. It is difficult to say exactly since you have not posted your entire code.

thomas_naveen 105 Junior Poster

Looks like your paste has expired.

Why don't you copy and paste the code here itself?

thomas_naveen 105 Junior Poster

Can you use the following?

myclass *myobjptr;
for(;;)
{
  myobjptr = new myclass(param1,param2);


  //Code

   delete myobjptr;
}

This is not really a good way of doing things as it might result in heap fragmentation due to the frequent allocation and deletes of memory involved.

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

Here is a tutorial on system. Maybe this will help you debug the issue.

thomas_naveen 105 Junior Poster

@msgeek

Please read the thread carefully. He/She has explained why your compiler might not be complaining.

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

After finding the matching name, why don't you continue searching the file until you see the next "Name", ignoring the lines in between.

thomas_naveen 105 Junior Poster

Commenting out line 25,26,27 should do it. (else part)

thomas_naveen 105 Junior Poster
thomas_naveen 105 Junior Poster

check for error in file opening after opening the file. Take a look here for more info regarding files

thomas_naveen 105 Junior Poster

Issue is data type mismatch.

prototype is

void ReadData( int[], string[] , string[] ,float[],int[] );

implementation is

void ReadData(int SID[],string FNAME[],string MAJOR[],float GPA[],float HRS[])

Either pass an array of floats to the function and change the prototype as well

or change the implementation to take an array of integers for HRS.

thomas_naveen 105 Junior Poster

replace line 9 with

printtable(10);

Note 10 has no significance here since the value of x is ignored.

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

Can you try with this

The problem that you are facing could be a "known issue".

thomas_naveen 105 Junior Poster

You seem to be doing quite well by yourself. What help do you need?

thomas_naveen 105 Junior Poster

Instead of pattern size use i-1 for the exit criteria

thomas_naveen 105 Junior Poster

Start converting what I have given you into code. (You are also welcome to ignore this logic and come up with something on your own)

Post the code and we can see.

thomas_naveen 105 Junior Poster

Pseudo code.

First line first element is always &.

else if not the first line, but the first element ( we need to print out variable amount of * based on the line number)

output linenumber-1 * and then an &.

else (now worry about placing the & at different locations inside the pattern.)
print out the & based on the relative position of j to i and also it should not be the first line.

else print out *


Do the same in both inner for loops

thomas_naveen 105 Junior Poster

Unless you give more information, it is really difficult to understand your problem.

For the program to understand a question mark, you would need to use an escape sequence.'\?'

Some more info on escape sequences

This is mostly meant for C.

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

How are you compiling the code?

Are you using manual commands from command line or are you using any Development Environment?

Would it be possible for you to post the exact command used for compilation?

thomas_naveen 105 Junior Poster

Please post the relevant code that you have tried so far.

Looking at the problem statement that you have specified, you can see a pattern. (The semicolon in the statement.)

You can use that for identifying a LOC, right?

Using such patterns, you can accomplish your objective.

thomas_naveen 105 Junior Poster

Instead of calling the function caclulateGrade in main, you are redefining it there.

Replace the below two lines in main with

int enterTotalQuestions(int tot_quest);
        double calculateGrade(double grade);

the actual function calls.

I can't give you an example because I would have to rewrite most of your code and that would defeat the purpose of practice for you.

thomas_naveen 105 Junior Poster

take a look at line 35.

You are trying to use an integer as though it is an array.

thomas_naveen 105 Junior Poster

First of all please use code tags and proper indentation.

Check the exit criteria of the last two while loops.

Are you doing anything to modify the elements checked in the while condition?

Will the condition ever be false?

thomas_naveen 105 Junior Poster

They are all pointers to Node. (Node*)

thomas_naveen 105 Junior Poster

Take a look at how you are allocating memory in your ListNode<Type>.

It might be a good idea to explicitly allocate memory for your pointers there and ensure that the memory is allocated on the heap, rather than assuming that the memory is allocated somewhere.

thomas_naveen 105 Junior Poster

I hope your prof has helped you.

If not, could you post the entire code? (with inputs given)