1,177 Posted Topics
Re: 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 | |
Re: 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 … | |
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 … | |
Re: 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 | |
Re: Maybe you can provide a sample input and resulting state/output? | |
Re: what is the problem? | |
Re: 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() | |
| |
Re: If it's a 3d game, you'll have to use either openGL or directX and use some sort of texture mapping. | |
Re: 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 … | |
Re: Here is a good explanation of left shift (<<) and right shift (>>) [url]http://irc.essex.ac.uk/www.iota-six.co.uk/c/e5_bitwise_shift_operators.asp[/url] Dave | |
Re: did you seriously just straight up ask someone to do your homework for you? | |
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 [code] from Geometry/Spherical import * [/code] rather than having to add every subdirectory … | |
I want to make an input stream parser capable of handling input in any of the following forms: [code] x y z x,y,z x, y, z (x,y,z) (x, y, z) [/code] Is there a clever way to do this? Or do I have to check the first character, if it … | |
Is it possible to indicate that a class function you are calling is static? [code] 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()); … | |
Re: Is there a way to declare the progress_display before initializing it, so you can do something like this: [code] 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 ; } } [/code] | |
Re: Here is what you are trying to do: [url]http://answers.yahoo.com/question/index?qid=20080422195554AAANJgl[/url] | |
Re: 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 … | |
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 … | |
Re: I haven't used it, but boost generally puts out pretty good libraries: [url]http://www.boost.org/doc/libs/1_39_0/doc/html/date_time.html[/url] | |
I was looking at this: [url]http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.18[/url] I don't understand [code] File f = OpenFile("foo.txt"); [/code] 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 … | |
Re: Is this an open source thing that we can download and try to compile? If so, please post a link. Dave | |
To redirect clog, I have been using this: [code] std::streambuf* clog_save; std::ofstream ofs; clog_save = std::clog.rdbuf(); ofs.open(LogFilename.c_str()); std::clog.rdbuf(ofs.rdbuf()); cout << "Test cout." << endl; std::clog << "Test log." << endl; std::clog.rdbuf(clog_save); ofs.close(); [/code] However, it seems like bad "code reuse" practice to have to put this in every program I … | |
Re: That is a linker error. You will not be able to find linker error's in the code. They have to do which which libraries you have your visual studio project linking to. I don't use visual studio so I can't tell you exactly, but you need to look in "project … | |
I usually make a matrix like this [code] from Numeric import * A=zeros([3,3]) print str(A[0,1]) #access an element [/code] I would like to store a pair of values in each element, that is have a matrix where the (0,0) element is (2.3, 2.4), the (0,1) element is (5.6,6.7), etc. Is … | |
I have to call this many times: [code] MyScript.py --top='?_0.png' [/code] where the 0 should be replaced with 0, 1, 2, 3, etc I tried this: [code] for i in {0..3}; do echo MyScript.py --top="'?_${i}.png'"; MyScript.py --top="'?_${i}.png'"; done; [/code] It seems to make the command look correct (ie the single … | |
| |
Re: haha yea, that is quite a challenging problem. You'd need at least an advanced degree in CS/EE or many many years of industry experience to even begin this problem. | |
I found some code to parse command line arguments (is there an easier way? sed always seems so complicated...) [code] #!/bin/bash for i in $* do case $i in --files=*) FILES=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;; --default) DEFAULT=YES ;; *) # unknown option ;; esac done echo $FILES echo "File … | |
I need to get an unknown number of file names from the command line, ie ./python MyScript.py --Files 1.txt 2.txt 3.txt [code] parser.add_option("-n", "--NumFiles", type="int", help="Number of files") parser.add_option("--Files", nargs=options.NumFiles, help="a triple") (options, args) = parser.parse_args() [/code] Clearly this will not work because options.NumFiles is not available until after parse_args() … | |
I want to parse some simple arguments from the command line. This shows all of the arguments: [code] #!/usr/bin/python import sys #print all of the arguments for arg in sys.argv: print arg [/code] but I want to handle something like [code] --file a.txt [/code] or [code] --x 12 --y 13 … | |
Re: You seem to have broken all of the rules at the same time.... | |
I tried to do this to redirect the clog output to a file: [code] ofstream ofs("file.log"); clog.rdbuf(ofs.rdbuf()); clog << "Logged." << endl; ofs.close(); [/code] It worked (the file contains the text), but the program segfaults. I read that you have to "restore" the original buffer, so I tried this [code] … | |
A friend of mine said that python could be used to make simple GUIs (ie. a couple of buttons and a text box). I googled "python gui" and it looks like there are 30934 libraries to make GUIs. Is there a "standard" or "built in" one? Thanks, Dave | |
Re: or you can put [code] using namespace std; [/code] up above all of the code. | |
Re: Can you make smaller but still compilable example of what is going wrong. We likely don't need to look at 100 lines to see the problem. Also, please use code tags. | |
Re: Some comments: There's probably no reason to use global variables. If the program expands, then they make things very confusing. [code] string getname(void) { cout << "Enter a name: "; string Name; getline(cin, Name); return Name; } [/code] This is called "parallel sorting". I posted how to do it here: … | |
Does anyone have a good 2 line summary of WHEN to use perl/python/bash/etc? To do easy-ish things, they can clearly all be used, but there is likely an ideology behind each that indicates WHEN/WHY to use them. For example, I use VB if I want easy GUI, c++ if I … ![]() | |
Re: you should use [code] for(int day = 0; day < days; day++) [/code] then just add 2^day (which is pow(day,2) in c++) to a running total. Dave | |
Re: You are missing a '{' between these lines. [code] double taxAmount(double taxRate, int perExempt, int numberofPeople, double taxRate) double taxRate; [/code] | |
Re: Can you extract and post the shortest example possible that will generate this problem? (so that we can compile it to track down the problem, but not have to look at 400+ lines of code) Dave | |
Re: I mean either the problem is impossible, in which case, well, it is impossible (ie the screen coords are not actually a function of the real coords), or, it is - there is really no middle ground! To see how many pixels (in x) are needed to represent 1 unit … | |
Re: It seems like you have just posted your homework assignment. Please give a try and check back here if you have any problems. | |
I am trying to do this [code] #!/bin/bash for i in 1 2 3 4 5; do File1="$i.txt" File2="$i.obj" ./Test $File1 $File2 #save i and the result of the program somehow done; [/code] For example, at the end I would like to have a file like this [code] 1 3.4 … | |
Re: ScienceNerd, please use code tags, it helps make the cod readable. Dave | |
I have used boost's progress bar (it outputs ***** from 0 to 100% complete) to track the progress of long loops. It would also be nice to be able to see a counter along with that, like if I run 1000 tests, the *'s will go from 0 to 100%, … | |
Re: Here are some of the answers: [QUOTE]What is the output of printf("%d")[/QUOTE] It will output some junk signed integer value because you never told it which signed integer to output. [QUOTE]Difference between "vector" and "array"?[/QUOTE] A vector is a STL container that has the same functionality as an array, but … | |
Re: I did some googling and from this same question on several other forums it seems like there is no way to retrieve this information. The reason seems to be that the stream may not even be a file, hence the file name would be ill-defined. The recommendations were to create … | |
Re: Not very efficiently, you could simply push the front() element onto the back of the queue, then pop it from the front. Do this until you get to the last element, but simply pop it instead of pushing and popping it. Because of the 'remark' I take it that this … | |
Re: you asked the same question 10 minutes apart.... this forum is for helping with programming, not doing your homework. |
The End.