thomas_naveen 105 Junior Poster

try putting the proper prototype at line 22.

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

try #define

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

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

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

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 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)

thomas_naveen 105 Junior Poster

You are passing by value. Try passing by reference.

thomas_naveen 105 Junior Poster

nested switch?

thomas_naveen 105 Junior Poster

Kindly let us know whether your issue is resolved?

If so, mark the thread as solved.

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
int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};

Try with the above modified days array.

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

You need to define the functions at the top of the file
or

in a header file and then include the header file.

thomas_naveen 105 Junior Poster

Try allocating memory to your dir variable. Similar to the command variable.

thomas_naveen 105 Junior Poster

28-31

void setY(int n)
           {            
                    x = n;
           }

This should be

void setY(int n)
           {            
                    y = n;
           }

Please check for more errors.

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

Take alook at the strcpy function.

The C string will have a terminating null character.

In the for loop,

for (indexer = 0;others[indexer];indexer++)

when the index (indexer) reaches the index of this terminating null character , the loop will exit.

Please use the CODE tags properly.

thomas_naveen 105 Junior Poster

double stands for double precision floating point number in C++

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

No. You will be calling seeding only after you have finished processing all your input parameters from command line.

Line 38 is outside the for loop where you are processing your command line parameters.

thomas_naveen 105 Junior Poster

What I meant was:

comment out seeding() on line 27.

Add the following on line 38

if(count)
{
       seeding();

}
thomas_naveen 105 Junior Poster

You can call the function immediately before you call cleanup either by itself or after checking for count.

thomas_naveen 105 Junior Poster

You are having a problem in line 32-36.

Instead of iterating through the linked list and adding your element at the end, you are pointing your head node to the new node and the new node points to your head.

All the intermediate nodes are lost. You are left with a LL of two nodes.

thomas_naveen 105 Junior Poster

I would like to see Event.h

Can you please upload the same?

Also, posting in bits and pieces of code is most irritating.

You are posting it because you don't know what the error is. Then how do you expect yourself to understand what part of code is causing the problem. Just because the compiler is pointing to one line doesn't make that line the culprit.

thomas_naveen 105 Junior Poster

you can use a function like

float calcPyramid(int length,int height)
thomas_naveen 105 Junior Poster

First of all you are passing radius to calcPrism and calcPyramid.

In those functions, the calculation is not based on radius.

The compiler fails to give any error , because you have the length,height and width defined as globals.

thomas_naveen 105 Junior Poster

First of all let me apologize that I cannot give too much attention to your problem.

But the first thing that I would do would be to rename my Polygon class, since it looks like there are two classes with the same name.

Another thing that could be done would be to define a copy constructor for Polygon.

Hope this helps.

thomas_naveen 105 Junior Poster

Move curly brace from line 60 to line 28. As it is all your functions are implemented inside main.

Remove the semi-column at the end of lines
29,37,42,47 & 52. these are implementation signatures.

Change the returns as previously suggested.

Add a line to do the operation first and then do the return.

netPay = wkPay - (fica + fwt);
return netPay;
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

Writing to a null pointer results in unexpected behaviour. My guess is that you were just lucky that it did not crash before. (I have no experience with Ubuntu)

The expected behaviour from the user side is to allocate memory to pointers before use and free that memory after use.

thomas_naveen 105 Junior Poster

You have 11 character pointers there with no memory allocated.

args[0] = (char*) malloc(sizeof(char));

*args[0] = 'l';

The above will allocate the memory that you want for a single character and during printing you should use %c instead of %s.

But from your way of initialising, I am guessing that you want 11 strings there instead of 11 characters.

You could go in for a two dimensional character array.

[EDIT]

Just multiplying the 'size of' above with the size of your required string should allocate the memory.

thomas_naveen 105 Junior Poster

Do the terms array of pointers, trying to write to a null pointer make sense?

thomas_naveen 105 Junior Poster
char *args[11];

Have you assigned anything to this variable before trying to print it out?

printf("args[%d  : %s\n", j, data.TheCommands[i].args[j])

You could consider removing the * in the args.

thomas_naveen 105 Junior Poster
int succeed = ParseCommandLine(buf, data*);

The above line does not make sense.

You want to pass the address of data to the function ParseCommandLine.

So the code should be

int succeed = ParseCommandLine(buf, &data);
thomas_naveen 105 Junior Poster

Finally got a VC++ 2008 compiler and ran this code through that.

The < operator needs to be overloaded as per the instructions given here.

Giving the code below.

class Node
      {
  
                       public:
  
                                      long state;
  
                                      int path_cost;
  
	                Node()
                       {
                                   //To be implemented
                       }
  
                        Node(long s,int p_c)
  
                       {
  
                                    state=s;
  
                                     path_cost=p_c;
  
                      }

	               friend bool operator<(const Node& x, const Node& y);
  
      };

       bool operator<(const Node& x, const Node& y)
      {

                  //To be implemented
		  return true;

      }

My overloaded operator is just returning true. You should implement the code as per your requirement.

I had to rename main and the args to main.

Default constructors needs to be defined for all the classes.

Some other minor errors are there which can be fixed by reading the error messages.

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

Could you please post the errors that you are getting now and start from Error 1?

Your previous post starts from Error4

thomas_naveen 105 Junior Poster

Please take a look at istringstream function usage.

I guess you would need to specify the second variable since you are using the

explicit istringstream ( const string & str, openmode which = ios_base::in );

function

thomas_naveen 105 Junior Poster

What error are you getting?

From looking at your code it looks like

Action();

the above way of defining your default constructor could be the problem.

If you would post the actual compilation error, I would be able to help you better.

thomas_naveen 105 Junior Poster

You could either modify the for loop reading the stream to regulate it to read only till EOF or add more elements to your data file

thomas_naveen 105 Junior Poster

just remove the following in your code

}// end class Cars


Public class Cars
{
thomas_naveen 105 Junior Poster

Avoid the semicolon after function signature in the definition part.

public void setItemName(string name);

Change

setItemTotal = total;
setItemPrice = price;

to

itemTotal = total;
itemPrice = price;
string

should be replaced with

String

Remove the second

public class Cars

and the braces for it.

thomas_naveen 105 Junior Poster

use

yOn = scn.next();

instead of

yOn = scn.nextLine();

at 196