daviddoria 334 Posting Virtuoso Featured Poster

Yikes, please don't use global variables!!

Here is my suggestion - take a step back away from the code and explain to us in English what you are trying to do. Maybe someone can then suggest an appropriate way to go about it.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I'm not exactly sure what is going on, but it looks like Form1 is in the PublishWizard namespace and you have not given a PublishWizard:: prefix or a "using namespace PublishWizard" when you try to reference Form1 in Utility.h

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I'm assuming you mean you have created some kind of table in c++? I would write it out as a CSV (comma separated value) file and the import it into excel using the CSV reader.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

The same way it generated the message telling me to email Dani? haha

daviddoria 334 Posting Virtuoso Featured Poster

Yesterday I received a "Site Temporarily Unavailable" message on daniweb.com. The instructions asked to send an email to inform Dani of the problem. I bet that almost no one actually does this. Would it make sense to add a button that simply says "click here to report the problem" and automatically generate this email? While I've never had a problem with daniweb.com uptime, this would probably help identify the problem asap.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Is the only way to get to the "advanced search" page by searching for a blank string? Should there be an "advanced search" link under the "Search" button?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I agree that it should be at the top. It took me a minute to find it after the change.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I agree with first person on that part.

As for the undefined symbol, I don't see anything obviously wrong. Again, you have posted 160 lines where probably 10 would do - I really suggest stripping everything down in a separate folder/project (just empty constructors basically) to try to isolate where the problem is coming from.

daviddoria 334 Posting Virtuoso Featured Poster

Calling a destructor shouldn't flush the stream. I don't know much about it, but there have been times that my output hasn't appeared when I expect it to and I've needed to flush the stream with an endl to fix it.

As for the constructors, since one of your classes is a derived class, it's constructor gets called along with its parent class constructor.

daviddoria 334 Posting Virtuoso Featured Poster

firstPerson - what is this supposed to do? Convert a string to an int? Shouldn't he just use a std::stringstream?

daviddoria 334 Posting Virtuoso Featured Poster

Please post the smallest compilable code that will produce this error.

:)

This is not just for fun - the idea is that it gets you to isolate the problem and hopefully solve it on your own!

So you are indeed including Player.h, so now we need to see the contents of Player.h

Dave

daviddoria 334 Posting Virtuoso Featured Poster

You're going to need to be a lot more specific than that! How are we supposed to know what you are trying to do??

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please post the smallest compilable code that will produce this error. "undeclared identifier" in this case probably means that you didn't include the header file?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

1. Why doesn't my 'char Menu::getSelection()' from my menu.cpp not display the cout stream? That's all I need it to do, for now.

I'm assuming by "display the cout stream" you mean it doesn't write anything to the console? I think you may need to flush the buffer by doing << std::endl;

2. Unsure if my 'showHiScore()' (which I hard-coded for display purposes only) is written correctly. I don't even get the cout stream. Any advice in this will be greatly appreciated.

What do you mean by "correctly"? What is it supposed to do? What does it currently do?

3. This one is just a nuisance, really: When the console program runs, I get "class Menu - Inside of 'Menu' default constructor" displayed twice. Why does it appear twice when the Menu constructor is defined only once within menu.cpp?

I imagine you are seeing the parent class constructor being called when you are instantiating a derived class.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I would put the numerical representation of the number into an std::string. From here you can access each digit separately:

std::string number = "123";
std::cout << number[0]; //outputs '1'

You would then have to have a giant switch statement to convert a '1' to "one", etc.

Hope this helps,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

You should be able to set the "working directory" in VC. That is where it will look for images without a path specified. Another thing you could check is that VC has the same library path order that your system has. Maybe it is linking to different versions of the libraries that you are using?

daviddoria 334 Posting Virtuoso Featured Poster

Can you produce the smallest piece of code that does this and post it here?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

You can construct the ssh string in your code (e.g. "scp file server") and then run it using the system() command. Did I understand your question correctly?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

If you don't want to do it, why should we??

daviddoria 334 Posting Virtuoso Featured Poster

Since there is no question, should this be moved to "code snippets"?

daviddoria 334 Posting Virtuoso Featured Poster

Unfortunately I don't have answer to your question, but I have two suggestions
1) make a much more descriptive title - this will entice people to investigate your problem
2) Please use code tags. This makes the code that you post much more readable.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

You can access each digit using a std::string

std::string number = "NAB";
    for(int i = 0; i < number.size(); i++)
      std::cout << number[i] << std::endl;

Dave

Ketsuekiame commented: Simple, yet effective. +1
daviddoria 334 Posting Virtuoso Featured Poster

Regular Expressions are very complicated, but very powerful. You can start reading here:
http://en.wikipedia.org/wiki/Regular_expression

But there should be millions of tutorials online. As for using the Boost Regex library, they have some examples, but I always find them very confusing. Give it a shot and maybe someone can help you if you have a specific problem.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I wouldn't do everything in the constructor. I would make it more like this:

Search mySearch;
mySearch.SetText("This is the text I want to search in");
mySearch.SetSearchString("want");
bool found = mySearch.Search();

This way you also can use the result in the calling function.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Can you take the input as a string and then check the length. If it is more than say 10 characters you can output "please don't input such large numbers" or something.

daviddoria 334 Posting Virtuoso Featured Poster

Please use more descriptive titles in the future!

daviddoria 334 Posting Virtuoso Featured Poster

I posted an example of how to use boost regex in this thread:
http://www.daniweb.com/forums/thread288358.html

Maybe it will get you started.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

First, you should fill these in!!

// void
// Purpose:
// Inputs:
// Ouputs:

They will really help your structure/logic.

I am concerned that your sort() function should not be doing anything with fstream - you should read the data elsewhere and pass it to sort().

I would highly recommend using std::vector over an array - it will certainly help you pass the data around.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Look into "exceptions" (throw and catch). It won't be a magic solution, you have to predict the run time errors. But it is better than nothing.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Of course those functions still work, ifstream just makes life easier :)

Some googling should get you a long way - let us know if you have any specific questions.

daviddoria 334 Posting Virtuoso Featured Poster

You should look into using ifstream. fseek, fgets, strtok, strchr, etc are all depricated.

daviddoria 334 Posting Virtuoso Featured Poster

You should see if there is an XML parser library for c++. This is pretty much exactly the idea of XML. Otherwise, just read in line by line, check for '[', then keep reading all of the lines until you hit another '['.

daviddoria 334 Posting Virtuoso Featured Poster

.size() tells you how many elements are in the vector.

God Coder123 commented: Thanks Dave really appreciate the help :) +1
daviddoria 334 Posting Virtuoso Featured Poster

Yea that is one thing I never figured out why they didn't include! I think you have to do:

array.push_back(1);
array.push_back(2);
array.push_back(6);
etc

Annoying, but the flexibility you get once it is built is MUCH worth it.

daviddoria 334 Posting Virtuoso Featured Poster

That wasn't my solution, so I'll let Aranarth answer, but I can suggest that if you use an std::vector<int> instead of an array the syntax gets much lighter - that is yourArray.size() vs sizeof(yourArray)/sizeof(*yourArray)

daviddoria 334 Posting Virtuoso Featured Poster

Please post your solution so others can benefit from a future search.

Also, please mark the thread as solved.

daviddoria 334 Posting Virtuoso Featured Poster

Please try to pose your question in a concise form such that it can benefit others in the future. That is, ask a question about c++, not about your program.

Some recommended reading...
http://daviddoria.blogspot.com/2010/05/problem-abstraction-helping-others-help.html

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Does this help?

int RandomInt(const int MAX)
{
	//produce an int from 0 to MAX-1
	return rand() % MAX; 
}

Dave

daviddoria 334 Posting Virtuoso Featured Poster

This code:

#include <iostream>
#include <vector>
using namespace std;

int main()
{

#include <vector>
std::vector<double> a;

int i =0;
while(1)
{
  a.push_back(i);
  i++;
}
  
  return 0;
}

produces

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
daviddoria 334 Posting Virtuoso Featured Poster

This is a pretty standard usage of switch. Have a look here:

http://msdn.microsoft.com/en-us/library/k0t5wee3(VS.80).aspx

daviddoria 334 Posting Virtuoso Featured Poster

-L (the path) tells it WHERE to look. -l (the libraries) tells it WHAT to look for.

daviddoria 334 Posting Virtuoso Featured Poster

Can you use a std::vector<list>?

Also I would be very careful with the name "list". If somewhere else std::list gets included, then you're going to have conflicts.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

NathanOliver -
It sounds like he wants to do something with this function:
http://msdn.microsoft.com/en-us/library/dt12193b(VS.71).aspx

I've never heard of the concept, but it doesn't sound like tie() does any actual outputting, but rather just forces an output to finish before starting an input.

What NathanOliver just recommended was in your original code, so I'm not sure what was wrong with that? Can you give an example file and tell us what the expected output current output are?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

You should use a vector<string> or vector<char> if you want to store things besides ints. Better yet, why not use a stack<char> which provides all of the functions you are looking to implement already?

daviddoria 334 Posting Virtuoso Featured Poster

The only difference is that you have a cin >> c_n_p; in the middle. What is the type of c_n_p? Hopefully someone can tell you how this cin statement interacts with the getline and cin.ignore() statements.

daviddoria 334 Posting Virtuoso Featured Poster

I don't understand the problem? I removed all of the code that we can't compile and the text and came up with this:

#include <iostream>
#include <string>
using namespace std;

int main()
{

  string test;
  
  cout << "1: " << endl;
  getline(cin, test);
  cin.ignore();
  cout << test << endl;

  cout << "2: " << endl;
  getline(cin, test);
  cin.ignore();
  cout << test << endl;
  
  cout << "3: ";
  getline(cin, test);
  cin.ignore();
  cout << test << endl;

  
  return 0;
}

Does this not behave as you would expect?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Can you tell us the application? Maybe someone will have a suggestion. Storing things as a void* always sounds like a bad plan to me...

daviddoria 334 Posting Virtuoso Featured Poster

fyezool,

Of course we can appreciate that English is not your first language, but please try to use "proper" English, rather than numbers and single letter words ("u 2", "sorry 4", etc)

Welcome to Daniweb.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please try to make your titles and questions as abstract as possible. This way the "next guy" can search and find something usable. If you ask "How do I randomly select an element of an array?" that is much more reusable than "How do I make a horse finish first?".

Dave

daviddoria 334 Posting Virtuoso Featured Poster

This is surely an OS dependent question - I'd say the only way to do it in c++ would be with a system() call to the appropriate OS command.

Dave