1,177 Posted Topics

Member Avatar for defender_

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

Member Avatar for defender_
0
154
Member Avatar for kesh1000

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 …

Member Avatar for Ancient Dragon
0
104
Member Avatar for daviddoria

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 …

Member Avatar for sneekula
0
136
Member Avatar for wnrqkflwnrqkfl

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

Member Avatar for daviddoria
0
82
Member Avatar for anthony95
Member Avatar for fadia
Member Avatar for vahiddani

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()

Member Avatar for vahiddani
0
119
Member Avatar for Vukinagauna
Member Avatar for Vukinagauna
0
100
Member Avatar for Arw

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

Member Avatar for amrith92
0
1K
Member Avatar for 35nando

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 …

Member Avatar for neigyl_noval
0
322
Member Avatar for Daria Shmaria

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

Member Avatar for Daria Shmaria
0
717
Member Avatar for azamalvi
Re: help

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

Member Avatar for tux4life
0
117
Member Avatar for daviddoria

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 …

Member Avatar for vegaseat
0
2K
Member Avatar for daviddoria

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 …

Member Avatar for ArkM
0
86
Member Avatar for daviddoria

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()); …

Member Avatar for siddhant3s
0
100
Member Avatar for kemarS

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]

Member Avatar for daviddoria
0
132
Member Avatar for newcook88

Here is what you are trying to do: [url]http://answers.yahoo.com/question/index?qid=20080422195554AAANJgl[/url]

Member Avatar for newcook88
0
163
Member Avatar for saravananrmca

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 …

Member Avatar for Salem
0
184
Member Avatar for daviddoria

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 …

Member Avatar for Ancient Dragon
0
86
Member Avatar for yamahammer342

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]

Member Avatar for Karkaroff
0
96
Member Avatar for daviddoria

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 …

Member Avatar for Ancient Dragon
0
294
Member Avatar for waldchr

Is this an open source thing that we can download and try to compile? If so, please post a link. Dave

Member Avatar for tux4life
1
640
Member Avatar for daviddoria

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 …

Member Avatar for ArkM
0
178
Member Avatar for ShadowScripter

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 …

Member Avatar for Ancient Dragon
0
268
Member Avatar for daviddoria

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 …

Member Avatar for vegaseat
0
103
Member Avatar for daviddoria

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 …

0
61
Member Avatar for snoopy198520
Member Avatar for harrykokil

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.

Member Avatar for ithelp
0
111
Member Avatar for daviddoria

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 …

Member Avatar for hexram
0
109
Member Avatar for daviddoria

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() …

Member Avatar for daviddoria
0
197
Member Avatar for daviddoria

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 …

Member Avatar for jlm699
0
111
Member Avatar for tomkeeee
Member Avatar for daviddoria

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] …

Member Avatar for Narue
0
120
Member Avatar for daviddoria

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

Member Avatar for jlm699
0
109
Member Avatar for cjswanson1355

or you can put [code] using namespace std; [/code] up above all of the code.

Member Avatar for siddhant3s
0
554
Member Avatar for BunnysMom

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.

Member Avatar for siddhant3s
0
101
Member Avatar for starter

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: …

Member Avatar for tux4life
0
97
Member Avatar for daviddoria

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 …

Member Avatar for leegeorg07
0
136
Member Avatar for orcsoul

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

Member Avatar for siddhant3s
0
535
Member Avatar for 1newguy

You are missing a '{' between these lines. [code] double taxAmount(double taxRate, int perExempt, int numberofPeople, double taxRate) double taxRate; [/code]

Member Avatar for siddhant3s
0
94
Member Avatar for guest7

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

Member Avatar for rm_daniweb
0
98
Member Avatar for Neo7

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 …

Member Avatar for Neo7
0
160
Member Avatar for namour84

It seems like you have just posted your homework assignment. Please give a try and check back here if you have any problems.

Member Avatar for ArkM
0
104
Member Avatar for daviddoria

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 …

Member Avatar for nucleon
0
162
Member Avatar for ScienceNerd

ScienceNerd, please use code tags, it helps make the cod readable. Dave

Member Avatar for daviddoria
0
83
Member Avatar for daviddoria

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%, …

Member Avatar for daviddoria
0
115
Member Avatar for prabhu_kar

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 …

Member Avatar for tux4life
1
145
Member Avatar for dekaya

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 …

Member Avatar for dekaya
0
2K
Member Avatar for student_x

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 …

Member Avatar for student_x
0
6K
Member Avatar for beddy085

you asked the same question 10 minutes apart.... this forum is for helping with programming, not doing your homework.

Member Avatar for beddy085
0
89

The End.