daviddoria 334 Posting Virtuoso Featured Poster

I suggest simplying your entire code to about the same length as you have posted. You don't show us any non-virtual classes, and you don't show how AlphaBeta is constructed.

daviddoria 334 Posting Virtuoso Featured Poster

It looks like you are reading in all of the values, then only writing out the matrix once. What you have looks good, but I would suggest making it into a function, and using variable names that are descriptive:

void PrintMatrix(int matrix[10][10]; const int numberOfRows, const int numberOfColumns)
{
for(int row = 0; row < numberOfRows; row++)
{
  cout<<endl;
  for(int column = 0; column < numberOfColumns; column++)
  {
    cout<<a[i][j]<<" ";
  }
}
}
daviddoria 334 Posting Virtuoso Featured Poster

QLabel::QLabel(const QLabel&) is called the copy constructor, and it is indeed private, so you cannot use it. You are trying to use it by copying your object when you pass it to the function. You should accept a const reference to the object instead:

void Test(const QLabel& yourLabel)

David

daviddoria 334 Posting Virtuoso Featured Poster

You are explicitly asking the user for the dimensions, so what is the problem? You have to assume either row-major or column-major (i.e. for:

1 2
3 4

row major ordering would be (1,2,3,4) where column major would be (1,3,2,4) ), but once you specify how you expect the input there is no reason to need line break characters, etc.

Also, please please please change variable names like 'd', and 'e' to "numberOfRows", etc.

David

daviddoria 334 Posting Virtuoso Featured Poster

Please include the entire compiler output. Which identifier is not found? My guess would be read_file, since you didn't declare it before main.

daviddoria 334 Posting Virtuoso Featured Poster

For starters, I would suggest never using spaces in a file name :)

If you insist on doing so, I think Windows likes backslashes instead of forward slashes - I don't if c++ cares about this.

Also, you may need to "escape" the space with a backslash:
read_file("F:/2nd\ year_2/Data structure 2/books/lecture-26.pdf");

daviddoria 334 Posting Virtuoso Featured Poster

You'll have to provide more information. Do you really need to store all 1000 of these 3000x3000 matrices? If so, then you're just out of luck :). Give us an explanation of the algorithm.

daviddoria 334 Posting Virtuoso Featured Poster

Yea if its getting to 95% right before it crashes that is definitely an "out of memory".

daviddoria 334 Posting Virtuoso Featured Poster

I think you should verify that it is indeed an "out of memory" before we look into it too far. I can't give you exact instructions because I'm on linux at the moment, but I believe if you open the task manager there should be some plots/statistics about cpu/memory usage. I'd leave that open while you run the program and if it goes up and up and up and gets to the top and then crashes then you've found the problem :)

daviddoria 334 Posting Virtuoso Featured Poster

Are you deleting the memory you are allocating with malloc? Depending on how big these matrices are, maybe you are running out of memory? Do you need to keep each of these 4000 matrices? Or just use it and then discard it?

daviddoria 334 Posting Virtuoso Featured Poster

Before messing around with a printBoard() function, you should make some examples for yourself to make sure you understand the basics. Create a string and output it. Does it look correct?

daviddoria 334 Posting Virtuoso Featured Poster

Before messing around with tictactoe, you should make some examples for yourself to make sure you understand the basics. Create a string and output it. Does it look correct?

Stringstream works just like "cin" (an input stream). Here is a demo:
http://programmingexamples.net/index.php?title=CPP/StringStream

David

daviddoria 334 Posting Virtuoso Featured Poster

I think your question would get better responses here: http://forums.libsdl.org/viewforum.php?f=1

daviddoria 334 Posting Virtuoso Featured Poster

It looks like you missed copying/pasting the critical line to answer this question! (The function declaration is missing!)

daviddoria 334 Posting Virtuoso Featured Poster

You should use more descriptive names. What is 'sz'? What does 'calc' do?

You should also post the shortest compilable example you can make that demonstrates the problem.

daviddoria 334 Posting Virtuoso Featured Poster

I suggest creating a function called OutputBinary(int lengthOfNumbers) and testing it by hardcoding a call to OutputBinary(3). This way you will be able to tell if the problem is with your output of if it is with your user input.

daviddoria 334 Posting Virtuoso Featured Poster

Sreekiran,

As a small side note, please use real English words like "please" instead of "plz" - it helps keep Daniweb looking professional!

daviddoria 334 Posting Virtuoso Featured Poster

I would start by switching from char arrays to std::string and from strcmp to .compare - http://programmingexamples.net/index.php?title=CPP/Strings/Compare
http://programmingexamples.net/index.php?title=CPP/IO/ReadingLines

daviddoria 334 Posting Virtuoso Featured Poster

I think you're missing two semicolons:

#include <iostream>

class Hop
{
protected:
  static struct NStrct
  {
    int nCount;
  } test;
};

int main()
{

  return 0;
}
daviddoria 334 Posting Virtuoso Featured Poster

If you want to use Qt it look like QConsole should do it: https://sourceforge.net/projects/qconsole/

daviddoria 334 Posting Virtuoso Featured Poster

A statement like this:

cin >> Total_Number_of_Seconds%3600;

doesn't make any sense. 'cin' is trying to read something from the input stream and store it somewhere. Storing it in "variable%3600" doesn't make sense. Just store it in "variable".

cin >> Total_Number_of_Seconds;

David

daviddoria 334 Posting Virtuoso Featured Poster

thelerner - Please mark the thread as solved. It helps so that the next reader does not read through your question only to find that it is no longer a question!

David

daviddoria 334 Posting Virtuoso Featured Poster

On line 57 'unique' is undefined.

If I define it, then I get:

In function ‘int unique_multiD(double**, int, int)’:

warning (really, error!): no return statement in function returning non-void
daviddoria 334 Posting Virtuoso Featured Poster

"calling the condition function gives me error" - what is the error? There should be no problem calling a function from another function.

daviddoria 334 Posting Virtuoso Featured Poster
for (i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
     cout<<list[i][j] << " "; // put a space between the characters on the same line
}
cout << endl; // start the next line
}
daviddoria 334 Posting Virtuoso Featured Poster

Please post your code directly using code tags. Preferably, simplify the code as much as possible so that it only demonstrates the relevant parts.

daviddoria 334 Posting Virtuoso Featured Poster

You should definitely check out Qt.

I have an introduction here:
http://rpi.edu/~doriad/Talks/Qt_Introduction.pptx

and a bunch of examples here:
http://programmingexamples.net/index.php?title=Qt

It will keep you pretty occupied!

David

daviddoria 334 Posting Virtuoso Featured Poster

Please mark the thread as solved.

daviddoria 334 Posting Virtuoso Featured Poster

1) Please use real English words - I.e. "please" instead of "plz".

2) You should be able to produce these same errors with about 10 lines of code, we do not want to look at 1200!!

3) These missing header files means your system either does not have those files or your include paths are not setup properly. Which compiler/operating system/IDE are you using?

daviddoria 334 Posting Virtuoso Featured Poster

You should post the code either directly on DaniWeb (using code tags) or on something like http://codepad.org/ .

And your teacher was right - you shouldn't use goto :)

David

daviddoria 334 Posting Virtuoso Featured Poster

Put them into an std::vector of std::string's and then std::sort() them:
http://programmingexamples.net/index.php?title=CPP/AlphebetizeString

WaltP commented: If he can't use char* properly, how the h*** can he use a friggin' vector? -3
daviddoria 334 Posting Virtuoso Featured Poster

You can't do this:

vector<long double> a;
a[0] = 1.0;

'a' hasn't been given any memory.

You need to do:

vector<long double> a(1); // give 'a' exactly one element
a[0] = 1.0;

or much better:

vector<long double> a;
a.push_back(1.0); // extend 'a' as needed

It is starting to seem like you are just trying to get this assignment done instead of learning c++ - I hope this is not the case!

daviddoria 334 Posting Virtuoso Featured Poster

That is fine, but you wont get the returned value.

Why are you passing a vector<long double> as a parameter?

The function should be defined like this:

std::vector<long double> IFS::yourFunction()
{

}

then you should call it with:

IFS yourClass;
std::vector<long double> returnedValue = yourClass.yourFunction();
daviddoria 334 Posting Virtuoso Featured Poster

Certainly:

std::vector<long double> IFS::yourFunction()
{
  vector<long double> a;
  return a;
}
daviddoria 334 Posting Virtuoso Featured Poster

The type before the function name is the return type:

std::vector<long double> yourFunction()
{
  vector<long double> a;
  return a;
}
daviddoria 334 Posting Virtuoso Featured Poster

Is this for a course assignment? I'm still not sure what you are trying to accomplish? The conditionals inside which you compute the 'tax' seem like a reasonable approach.

daviddoria 334 Posting Virtuoso Featured Poster

What are all of those cutoff* variables? Why wouldn't you just assign the calculations to 'tax' as was done originally?

daviddoria 334 Posting Virtuoso Featured Poster

So it sounds like you've already narrowed it down to the shared_secret_key function. If you can give us a sample input, the desired output, and the current output to this function maybe someone will be able to spot the problem. That is, I bet you can reduce thes 180 lines to about 15 lines that demonstrate the problem.

David

daviddoria 334 Posting Virtuoso Featured Poster

Sure thing. Please mark the thread as "solved" if you're all set with this question.

David

daviddoria 334 Posting Virtuoso Featured Poster

The function returns void (i.e. nothing) so you can't output it. Simply do:

std::cout << a << " " << b << std::endl;

David

daviddoria 334 Posting Virtuoso Featured Poster

You did indeed use the tags properly :)

Method 1

struct MyStruct
{
int a,b;
}

MyStruct IFS::eval(int x, int y)
{
 int a = ...
 int b = ...
 MyStruct mystruct;
 mystruct.a = a;
 mystruct.b = b;
 return mystruct;
}

.....

Call with:

MyStruct result = IFS::eval(x,y);

Method 2:

void IFS::eval(int x, int y, int &a, int &b)
{
 a = ...
 b = ...
}

Call with:

int a, b;
IFS::eval(x,y,a,b);

I hope this helps!

David

megaLU commented: Very helpful thank you +0
daviddoria 334 Posting Virtuoso Featured Poster

Welcome to DaniWeb!

You could do two things.

1) Make a struct, fill the struct with the two values, and return it.
2) "Return" a and b by reference.

Also, please use code tags when posting code.

Good luck,

David

daviddoria 334 Posting Virtuoso Featured Poster

Excellent - I'm glad it's working, and I'm even more glad you've learned something! Yes, you definitely want to split the code into as many functions as possible (ok, ok, don't go crazy), but more functions typically makes code easier to debug and test.

Also, please mark the thread as solved.

David

daviddoria 334 Posting Virtuoso Featured Poster

The declaration of GetEncoderClsid must come before the definition of gdiscreen() (since gdiscreen() calls GetEncoderClsid). A good practice is to put all of your function declarations right after the includes. Putting it inside main() as you have done doesn't make sense.

daviddoria 334 Posting Virtuoso Featured Poster

If that is your entire program, you are definitely missing main(). From main, it looks like you should call gdiscreen(). The "identifier not found" would be fixed by adding a declaration before you call the function:

int GetEncoderClsid(const WCHAR* format, CLSID* pClsid);

David

daviddoria 334 Posting Virtuoso Featured Poster

Definitely. Threads are absolutely how you do multiple things at the same time.

daviddoria 334 Posting Virtuoso Featured Poster

Haha, we needed a mutex (or one of those other words I don't really understand... :) )

daviddoria 334 Posting Virtuoso Featured Poster

You are looking for "threads". Boost has a fairly easy to use thread (a simple example: http://programmingexamples.net/index.php?title=CPP/Boost/Threads) and Qt also has one (QThread). Don't be fooled though, threads get very complex very quickly, so you'll have to do your homework :)

daviddoria 334 Posting Virtuoso Featured Poster

Ah, yes, sorry. I've never profiled code in Windows.

daviddoria 334 Posting Virtuoso Featured Poster

I use KCacheGrind to look at the output of valgrind's callgrind option.