thomas_naveen 105 Junior Poster

Try replacing Tile with Tile1 and also remove the '()' on line 35.

thomas_naveen 105 Junior Poster

Post your whole code or attach it as files.

thomas_naveen 105 Junior Poster

Googled and found this link. Looks very similar to your problem.

thomas_naveen 105 Junior Poster

From your explanation, it looks like the problem could be the getVal function.

Could you try and re-write the for loop in getVal so that there is a proper exit condition here?

for (j=0;nent--;j++)

I am not having access to a compiler and hence can't say whether it is valid or not.

thomas_naveen 105 Junior Poster
thomas_naveen 105 Junior Poster

Have you tried using strcmp instead of == in the if check?

thomas_naveen 105 Junior Poster

Assumptions:

I am assuming that your problem statement refers to position.

Shift up means previous row and shift down means next row.

Shift left means go to the previous column and shift right means go to the next column.

In that case

0    1    2


0   R    D    L


1   D    L    U

For the above array, starting from 1, 1.

L means go to 1,0. (D)

D at (1,0) pushes the value to 2,0 which is out of bounds and the iteration should end there without accessing the 2,0 element.

If you have had the patience to read this far,

the above check can be done by putting the code in a loop, where you implement proper checks and read the array based on row and column values.

Exit:

Exit condition should be when the array goes out of bounds. (Take care not to read the out of bounds value by putting a check on your row and column counters.)

Have another exit condition which checks that after n proper traversals in the array the loop exits.

thomas_naveen 105 Junior Poster

In C++, arrays start from index 0. In your case that would be row 0 column 0. Not sure what you mean by entry point. Do you want to start from row 1 column 1?

'=' is not a comparison operator. It is an assignment operator.

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

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

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

Reading your problem statement makes no sense, what exactly is the problem that you are facing?

thomas_naveen 105 Junior Poster

Is this what you are looking for?

thomas_naveen 105 Junior Poster

You might want to consider changing

c= n

and

r= m

with

c== n

and

r== m
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

Write the data to a temporary file and rename it as fruit.txt

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

try using sprintf

thomas_naveen 105 Junior Poster

Hope this article helps.

thomas_naveen 105 Junior Poster

The code changes suggested by JuhaW should be maintained as such. Just because, you are still getting SEG fault doesn't make the necessity of allocating memory to a NULL pointer go away.

if (strncmp (&in_rec[OM_TRAN_CODE],OHAD, 4)==0)

Can you explain what is happening at this line. It looks like you are accessing 4 bytes beyond the end of the in_rec array. You should consider changing that to

if (strncmp (in_rec,OHAD, 4)==0)

I hope OHAD is a character array that you have defined?

thomas_naveen 105 Junior Poster
memcpy(root->message,&in_rec,s_siz);
memcpy(temp->message,&in_rec,s_siz);

You need to allocate memory for the message as well.

Otherwise you can make message a non pointer variable.

struct host_msgs_list
{
struct host_msgs_struct message;
struct host_msgs_list *next;
};
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

thomas_naveen 105 Junior Poster

Look at my edited post. Make that change and the following changes as well.

several issues that I failed to spot at first are:

public void setItemTotal(int total);

No semicolon is needed at the end of this line.

Same problem exists at other places as well.

private double totalInventory;

is not being used anywhere in the program.

Also , please use code tags when you post


[EDIT]

One thing more is that you should not be using two 'Cars' classes. Change one to CarDriver or something.

The two classes should be in two files and the file name should correspond to the class name.

Better still use a package for both these classes.

thomas_naveen 105 Junior Poster

try

itemTotal = total;
itemPrice = price;

instead of

setItemTotal = total of cars;
setItemPrice = price per car;
thomas_naveen 105 Junior Poster

http://www.daniweb.com/tutorials/tutorial71858.html

check out the above tutorial.

Get your input as a string and then compare it with the valid inputs that you can have.

This way you can avoid using letters in the arithmetic.

thomas_naveen 105 Junior Poster

The second link given by BJSJC gives you most of the info required.

Check out the below link as well.

http://java.sun.com/docs/books/tutorial/2d/printing/printable.html

thomas_naveen 105 Junior Poster

There is no need to beg.

Looks like

void div(){

is not getting closed.

Put one more curly brace before main()

[EDIT]

use

int main()
thomas_naveen 105 Junior Poster

If you want more information of design patterns it would be a good idea to refer to a book like HeadFirst. I am sure that googling also would result in a good number of sites giving details of all the design patterns out there.

The basic idea of singleton is to have a single instance of a class.

An example where I have seen singleton implemented (C++) was an engine where we needed only one instance to run at a time.

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

You are referring to two different functions in your code.
a_star and a_start. Try renaming them to the same name.

Ex: a_star is defined at line 26.
a_start is implemented at line 179.

Rename them both to a_star and modifying your function calls also should help.

thomas_naveen 105 Junior Poster

You should be using

#ifdef fst

in your code check instead of

#if (fst == 1)
#define fst 1

The above line is an indicator to replace fst with 1 whenever seen.

So (fst == 1) translates to (1==1)

The #define is used for many purposes like ,
1)For defining constants.
2)For conditional excution of code.
3)For making sure that multiple inclusions of header files are avoided.

You can also write macro code using this directive.

thomas_naveen 105 Junior Poster

Have you tried using sprintf to print the hex formatted numbers onto a string.

thomas_naveen 105 Junior Poster

Why should 10.1 be greater than 10.5?

Can you add your code to the post so that there is more clarity?

thomas_naveen 105 Junior Poster

try copying the following line at the top of your file

#define _GNU_SOURCE
thomas_naveen 105 Junior Poster

Thanks...

Please mark the thread as solved.

thomas_naveen 105 Junior Poster

You could try giving the prototype of the function at the start of the program.

void Wander(double *forwardSpeed, double *turnSpeed);

Kindly use code tags while posting code..

thomas_naveen 105 Junior Poster

Like I said before, you are not closing your file pointers after opening them.

I saw one instance in "outlink_gen" function. The "out_fp " file pointer needs to be closed.


Please go through the code to see if there are any more such instances.

You can debug your code using some debugger like gdb.