daviddoria 334 Posting Virtuoso Featured Poster

1) put your code in "code" tags
2) compile it yourself and report any errors!

daviddoria 334 Posting Virtuoso Featured Poster

Please make the title of your thread informative - e.g. "Opening a cdrom drive".

daviddoria 334 Posting Virtuoso Featured Poster

Please wrap your code in "code" tags. Also, please give us a sample input, the current output, and the expected output.

I don't think you need this: #include "stdafx.h" You should use #include <cmath> instead of #include <math.h> Another rule is that you should pretty much never use using namespace std; Dave

daviddoria 334 Posting Virtuoso Featured Poster

also, there should be no "=" in this line:

return strcspm(mystring,letter);

also, did you mean for "strcspm" to be "strcpn" ? If so , that lives in cstdio

daviddoria 334 Posting Virtuoso Featured Poster

What are you talking about? What is the code supposed to do? Can you give sample input, expected output, and actual output?

daviddoria 334 Posting Virtuoso Featured Poster
#include <iostream>

is where you will find cout, etc.

namespaces are ways to group functions - for example, the cout, etc you are looking for are in the std namespace, so you have to call them like this:

#include <iostream>

int main()
{
std::cout << "something" << std::endl;
return 0;
}

Other useful things in the std namespace:

#include <vector>
#include <string>
etc.

good luck

dave

daviddoria 334 Posting Virtuoso Featured Poster

You could use a switch statement instead of an if and a bunch of else ifs - I never really got the difference but it's something for you to fool around with.

daviddoria 334 Posting Virtuoso Featured Poster

Why do you want to read a character at a time? Why not use std::getline() to read a line at a time into an std::string?

daviddoria 334 Posting Virtuoso Featured Poster

I don't think this is really a c++ question at all, sorry Peter.

daviddoria 334 Posting Virtuoso Featured Poster

Are you talking about these functions?
http://www.codersource.net/cpp_date_time.html

daviddoria 334 Posting Virtuoso Featured Poster

what is an "academic automation system"? You should probably ask much more specific questions about code that is not working.

daviddoria 334 Posting Virtuoso Featured Poster

Yea, I think that generally the convention is to not include .cpp files. Surely you can make a project with any IDE. CMake is becoming pretty popular - it is a "crossplatform project building" utility - that is, in linux, you can generate a makefile or a KDevelop project. In windows you can generate a visual studio project. It's much much easier than writing makefile yourself for large projects, but for this small of a project I'm sure you could find a makefile tutorial online (this one looks reasonable http://www.opussoftware.com/tutorial/TutMakefile.htm)

Dave

tux4life commented: Yes, that one looks reasonable :) +8
daviddoria 334 Posting Virtuoso Featured Poster

mrniceguy - you're going to have to put in some effort before anyone here will help you. Give it a try and then we can take a look and see where you've gone wrong.

daviddoria 334 Posting Virtuoso Featured Poster

With this low level of code it is probably better posed in the C forum than the c++ forum - I'd give it a try there.

daviddoria 334 Posting Virtuoso Featured Poster

You can just throw them all into an std::set and then read them out into a vector. It will take care of the duplicates for you.

daviddoria 334 Posting Virtuoso Featured Poster

Please post the smallest example that you can extract, a sample input, the expected output, and the current output.

daviddoria 334 Posting Virtuoso Featured Poster

I believe the preferred method of reading all the lines in a file is this:

std::string line;
	
while(getline(fin, line))
{
	//the current line is now in "line", handle it
}
daviddoria 334 Posting Virtuoso Featured Poster

Thanks for that useful answer William Hemsworth!

daviddoria 334 Posting Virtuoso Featured Poster

I believe what ithlep means for you to do is

MyFrame *mainFrame = new MyFrame(wxT("Test Harness"), wxSize(700, 600) ); 
if(mainFrame)
  mainFrame->Show(true);
else
  std::cout << "There was an error creating mainFrame!" << std::endl;
daviddoria 334 Posting Virtuoso Featured Poster

Please provide the smallest possible segment of code that isn't working, along with example input and actual output vs expected output.

daviddoria 334 Posting Virtuoso Featured Poster

Where is CString declared? Is it a visual studio thing? Because CString is definitely not a standard c++ thing.

daviddoria 334 Posting Virtuoso Featured Poster

Wow, you didn't even take the time to say "I have this assignment, can you help me?" - you just copy and pasted directly!!

daviddoria 334 Posting Virtuoso Featured Poster

You could also use an std::vector of your struct to avoid almost every problem that will come up.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please post the smallest version of your code that will produce those linker errors. Then we can see which libraries you are trying to use.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

The first compiler error I get is that your struct data_to_pass_st isn't defined anywhere. Also, I don't know where common.h is - maybe it is a windows thing?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Sounds like he was asking more about GUI type stuff rather than 3d graphics? In linux, there are a couple of main GUI libraries like QT and GTK. I'm not sure about windows. They usually have some kind of graphical designer that you can layout buttons and textboxes and whatnot, then they use some variation on the idea of "callbacks" - an event gets triggered when the user does something in the GUI and then you have to "handle" the event in the code.

Sorry, I don't know anything about windows GUIs in c++.

Good luck.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Can you abstract the question to something like "how do you input everything the user types until the enter key is pressed?" or something like that? I'd say 3/4 of those lines are not related to your question. Please post
1) the shortest example possible that demonstrates the problem
2) a sample input
3) the current output
4) the expected output

and then we can probably help :)

Dave

tux4life commented: Agreed :) +7
daviddoria 334 Posting Virtuoso Featured Poster

If possible, can you extract the problematic part of the code and post it so we don't have to download a file? Maybe you can make a very small example that demonstrates the problem without having the overhead of the rest of the code.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please use code tags to make the code readable.

You probably don't want to read the data a single character at a time - consider using cin.getline() to get a line at a time. Also, if you store things in a std::vector, you can then use the std::sort() function to sort the GPAs.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I'm just starting python and it seemed reasonable to go ahead and learn the new version. I read that numpy wont be available for python3 until at least 2010. All I need is a basic "vector", "matrix", and some basic functions like matrix/vector multiplication. Is anything like this available for python3?

Thanks,
Dave

daviddoria 334 Posting Virtuoso Featured Poster

You don't have a semicolon after num++. There is no reason that I should have to compile your code to find out what the compiler errors are... post the compilers output next time. Also, there is not need to post 10 line cout statements, you should post the simplest working example possible. The following code has the same problems, but is much shorter.

#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;
int main ()
{
	int num;
	do
	{
		cout<< "something" <<endl;
		cin>>num;
		cout<<endl;
		num++
	
	}while(num!=0);

	switch (num)
	{

		case (0):
			cout << "End of program"<<endl;
		case (1):
			cout<<"something else"<<endl; 
			break;
		default:
			cout<<"Invalid number. Please choose again.";
			break;	
	}
	return 0;
}

You don't seem to be handling case 0 at all, if you want to end the program you could use

return 0;

or

exit(-1); //from stdlib

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Maybe you can provide a sample input and resulting state/output?

daviddoria 334 Posting Virtuoso Featured Poster

You just want to copy lines 5-100 out of one file and into another file? You could use c++ for that - look into fstream and cin.getline()

daviddoria 334 Posting Virtuoso Featured Poster

what is the problem?

daviddoria 334 Posting Virtuoso Featured Poster

If it's a 3d game, you'll have to use either openGL or directX and use some sort of texture mapping.

daviddoria 334 Posting Virtuoso Featured Poster

If the problem is indeed in a library and you not doing anything incorrectly, maybe try exit(0) (from stdlib) as the last line of the program? I don't know if that would help? It would be nice if you could kind of find where it happens though so you could report the problem to the mailing list/forum for that library.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Here is a good explanation of left shift (<<) and right shift (>>)
http://irc.essex.ac.uk/www.iota-six.co.uk/c/e5_bitwise_shift_operators.asp

Dave

daviddoria 334 Posting Virtuoso Featured Poster

What is the problem? Also, please use code tags.

daviddoria 334 Posting Virtuoso Featured Poster

did you seriously just straight up ask someone to do your homework for you?

daviddoria 334 Posting Virtuoso Featured Poster

sneekula - you'd still have to put a line for every single subdirectory though, right?

What I'm saying is I'd just want to add "/home/doriad/PythonScripts" to my PYTHONPATH and then any subfolders of PythonScripts will be automatically searched - the idea being that if I rearrange the contents of PythonScripts and change the names of subfolders, etc I will not have to update my PYTHONPATH.

Does that make sense?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I want to make an input stream parser capable of handling input in any of the following forms:

x y z
x,y,z
x, y, z
(x,y,z)
(x, y, z)

Is there a clever way to do this? Or do I have to check the first character, if it is '(' then do one thing, if it is not then read a double, then check if the next character is a ',', etc etc.

Is there a robust way to handle these types of inputs?

Thanks,
Dave

daviddoria 334 Posting Virtuoso Featured Poster

Is it possible to indicate that a class function you are calling is static?

class Point
{
std::string name;
	public:
		Point(){}
		static void DisplayName() { std::cout << "Point" << std::endl;}
};

int main()
{
  Point.DisplayName(); //this doesn't indicate the the member function is static
//maybe something like this:
//static_call(Point.DisplayName()); //just to indicate to the reader that this call makes sense without an instance of the class
}

There are several times where I dont remember even in my own code that I am calling a static function.

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

If I have /home/doriad/Scripts/Python/
and inside I have a bunch of folders, ie Geometry, Math, Other, etc that each contain scripts (.py files), is there a way I can just add /home/doriad/Scripts/Python to PYTHONPATH and then somehow

from Geometry/Spherical import *

rather than having to add every subdirectory to the PYTHONPATH explicitly?

Thanks,
Dave

daviddoria 334 Posting Virtuoso Featured Poster

Is there a way to declare the progress_display before initializing it, so you can do something like this:

void MyFunc(const bool progressbar)
{
boost::progress_display display;
if(progressbar)
  display = boost::progress_display(LINES_IN_FILE);
  for( int i=0 ; i<LINES_IN_FILE ; ++i )
  {
    //do something
    if(progressbar)
       ++display ;
  }
}
daviddoria 334 Posting Virtuoso Featured Poster
newcook88 commented: Thank you for the link i wud appreciate if u can show a method to print the output that vector +1
daviddoria 334 Posting Virtuoso Featured Poster

I've not heard of that speedup - you're saying that if one region in the image is the same as next region, there is not need to compute the correlation again? I don't see how the algorithm would have any way of knowing that (besides some operation that would take just as long as the actually correlation).

daviddoria 334 Posting Virtuoso Featured Poster

I have a "Tools" class which contains a lot of functions I commonly use. One is a parallel sort. I pass it a vector of Objects and a vector of indices, and it sorts the Objects and sorts the indices the same way (so the corresponding index is in the same position as its original corresponding object). The problem is, if I want to do this with a type that is unknown to Tools, it complains (makes sense... haha). Is there a way to define the < operator for Object somehow such that I can do this without having to modify Tools?

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I haven't used it, but boost generally puts out pretty good libraries:
http://www.boost.org/doc/libs/1_39_0/doc/html/date_time.html

daviddoria 334 Posting Virtuoso Featured Poster

So it's really not that beneficial, you can just write:

T.setB(4).setC(5);

instead of

T.setB(4); T.setC(5);

?

daviddoria 334 Posting Virtuoso Featured Poster

I was looking at this:
http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.18

I don't understand

File f = OpenFile("foo.txt");

It seems like File is one class, and OpenFile is a separate class, so how can you assign an OpenFile to a File?

Also, is it necessary to have this second class? Why not something like this:

#include <iostream>

class Test
{
	private:
		int A,B,C;
	public:
		Test& setB(const int b)
		{
			B = b;
			return *this;
		}
		
		Test& setC(const int c)
		{
			C = c;
			return *this;
		}
		
		Test(const int a) : A(a) 
		{
			B = 0;
			C = 0;
		}
		
		void Output()
		{
			std::cout << A << " " << B << " " << C << std::endl;
			
		}
};

int main(int argc, char *argv[])
{
	Test T(1).setB(4);
	T.Output();
	
	return 0;
}

(This gives me "unexpected ',', ';', or '.'" on the Test T instantiation)

Any thoughts?

Dave