1,177 Posted Topics
I have recently taken over as a volunteer webmaster for this website: [url]http://www.ewh.ieee.org/r1/schenectady/newsletter.html[/url] Under the "Schenectady Section News" heading, you can see that there are a bunch of simple pages that all look the same. The current process to add a new one is to copy and paste an old … | |
I put a simple script: [code] <? php print "Hello world"; ?> [/code] here: [url]http://ewh.ieee.org/r1/schenectady/HelloWorld.php[/url] When I go to the page, I don't see "Hello world" displayed. Does that mean PHP is not enabled on the server? Thanks, David | |
Re: This is a pretty standard "first assignment". Please show us that you have tried. You won't get any help until you post some code and show us where you are stuck. David | |
Re: Here are some observations 1) You should definitely use an std::vector<double> instead of a fixed length array. There is no reason to arbitrarily restrict the user to 75 inputs. If you don't change this, you should certainly check if the counter goes above 75 and throw an error if it … | |
Re: That is definitely the best way, I agree! You can go to github.com, gitorious.org or [url]http://code.google.com/[/url] and search for projects (they are just like sourceforge). I'm sure people would be happy to have some help. Good luck, David | |
| |
Re: You had me pretty confused on this one. It seems like qApp is a macro or something (reserved word). I changed it to: [code] QApplication a(argc, argv); return a.exec(); [/code] and then it worked fine. David | |
Re: Here is the fix for your error - you have to dereference the value: [code] if(*(CGraf::matr_adi[C[p],i])==1) [/code] But yikes, you really really really should consider using more descriptive variable names, and COMMENT COMMENT COMMENT! There is some personal preference involved, but here is what I would change: matr_adi -> AdjacencyMatrix … | |
Re: Definitely no need to wait. 0x will just make some things easier for you, but probably not until you've got at least a couple of years of experience with the "old" c++. Definitely continue with your book for the concepts, but there are some good examples of how to do … | |
Re: Please start a new thread when you have a new question. What you have done here (posting a new question at the bottom of an existing thread) is called "thread hijacking" and is very frowned upon :( | |
Re: What is the error? What is the expected output? What is the current output? | |
Re: What is the output supposed to be? What is the current output? | |
Re: I'm assuming this is for a course (if it is not, use a library (VNL, Eigen, etc)). It if is, I'd imagine you need a Matrix class and overload the * operator for it. Internally you could store an array[9] or an array[3][3]. | |
Re: I have no idea what is going on there, but if it is in an infinite loop then flag is never getting set to 1. I STRONGLY suggest breaking a lot of this code out into functions. I.e. [code] void GenerateRandomNumbers(int rands[][]) { rands[i][0] = 600.0 * rand()/RAND_MAX; // for … | |
Re: I would do two things to start debugging. First, get rid of the user input and hardcode some values. Once it works with the hardcoded values, you can put the user input back in. Second, write out the steps of the algorithm for the same values you have hard coded. … | |
Re: Look up "iostream", "cin", "conditionals" ("if"), and "mod" ("%"). David | |
Re: You could use Qt. It is nice and also cross platform :) Here are some examples: [url]http://programmingexamples.net/index.php?title=Qt[/url] | |
Re: Here is an example of the nested vectors that Nick Evan mentioned: [url]http://programmingexamples.net/index.php?title=CPP/2DVector[/url] Also, what is going on here? [code] array[n][n]>>board[i][j]; [/code] | |
Re: You may want to ask on the OpenSSL mailing list: [url]http://www.openssl.org/support/community.html[/url] | |
Re: I think "code snippets" are intended to be "here is my working code, I thought it may help others". In your case, with a question, you should just make a normal "thread". | |
Re: The templated sum() function tries to add a to b. Your + overload adds a.time to b.time. It should work if you call: [code] int total = sum<int> (hw.time, hw2.time); [/code] David | |
Re: If it is a complicated structure, there is probably not a better way than to require the user to use multiple of your classes (the classes inside (composing) the big class). Sounds fine to me. | |
Re: I strongly suggest you add many comments to your code. At the very least, there should be one or two sentences at beginning of every function telling the reader what the function is supposed to do. You can also give us a sense of what the entire program is supposed … | |
Re: Your choice of those two functions seems fine, you just have to implement them! Here is a good place to start: [url]http://programmingexamples.net/index.php?title=CPP[/url] Particularly: [url]http://programmingexamples.net/index.php?title=CPP/IO/FileInput[/url] and [url]http://programmingexamples.net/index.php?title=CPP/IO/ReadingLines[/url] . Also, please use code tags when posting code. David | |
Re: Sure, just keep the files on the usb drive! VC won't care whether they are on the C drive or some other (F, perhaps) drive. | |
Re: Yikes that is a lot of code. Can you try to simplify it down to < 40 lines or so? Also can you explain exactly what is wrong? Is it crashing? Is it giving an incorrect result? Dave | |
Re: I believe the idea of inline functions is that it will make small functions run faster. It seems like an "old school" concept - can someone testify that it still makes a significant difference on modern compilers? Maybe provide a short example program and some timings? This seems like a … | |
When trying to pass a template parameter to another template, I am getting an 'invalid template parameter' error. I even tried to force it with 'typename' with no success. Can anyone see what's wrong with this? [code] #include <itkImage.h> #include <itkImageFileWriter.h> #include <itkRescaleIntensityImageFilter.h> template <class T> void WriteImage(typename T::Pointer image, … | |
Re: It seems like you are explaining two things. The first is that the program opens, reads a file, updates the file, then closes. The second is that you are doing this read/write in a while loop? fstream is definitely the way to go for the file IO. Then you should … | |
Re: Search sounds like a good way to go. I don't know what you mean by it uses "an array to search", but this shouldn't use any extra memory, it looks you just specify a range of indices which is your search patter, and a range of indices in which to … | |
Re: 1) First, you should include cstdlib: [code] #include <cstdlib> [/code] Not doing so causes compiler errors on many systems. 2) Another, more serious error is: [code] cout<< count << " is located at col " << countNum(ar,10,col)<<" row " <<countNum(ar,10,row)<<endl; [/code] 'col' and 'row' are not defined! You need to … | |
Re: I think even though you have include guards, you can't declare a function in the header, you can only define it. That is, you need to change the header to: [code] #ifndef GENERALFUNCTIONS_H #define GENERALFUNCTIONS_H bool IsFiniteNumber(double x); #endif /* GENERALFUNCTIONS_H */ [/code] And then in the implementation (.cpp file), … | |
If I use a template function with T where T = itk::Image<unsigned char>::Pointer, everything is fine: [code] #include <itkImage.h> class Test { public: template <class T> void Add(T patch); }; template <class T> void Test::Add(T patch) { } int main(int, char*[]) { Test a; itk::Image<unsigned char>::Pointer image; a.Add(image); return EXIT_SUCCESS; … | |
Re: What are CArray and CString? To set a member of a struct, you first have to instantiate it: [code] student myStudent; [/code] Then you just use a '.' : [code] myStudent.Struct_Name = "David"; [/code] | |
Re: I'd look into cin and std::string. Also, multiply is * in c++ :) | |
Re: You could ask here or here: [url]http://old.nabble.com/SDL-f14250.html[/url] [url]http://forums.libsdl.org/viewforum.php?f=1&sid=16b16a0f4004197730c6fc82a9ebc3fd[/url] Dave | |
Re: changing to release mode just tells it not to run the assert commands. that is a TERRIBLE idea because now something is going wrong, its just not telling you! It will come back to bite you for sure! Use step through in debug mode to see which line the assert … | |
Re: 1)I have to include [code] #include <cstdlib> // for srand [/code] to define the srand() symbol. 2) There is no reason for all of this: [code] random_integer = rand() % (HIGH - LOW + 1) + LOW; [/code] Since you just want a number from 0 to 1, you can … | |
Re: You just need to change [code] variance(arraym[299][299], minl, minw, rlm, rwm); [/code] to [code] variance(arraym, minl, minw, rlm, rwm); [/code] This compiles for me: [code] #include <cstdlib> #include <iostream> #include <string> //mean function double mean(int arraym[299][299], int minl, int minw, int rlm, int rwm) { double sum(0); int n(0); for … | |
Re: I would try to simplify the problem down to < 50 compilable lines that you can post directly to daniweb (using code tags). It is much easier for people to review than having to download your files. | |
Re: FYI the terminology is "passing a 2d array to a function". Here are multiple solutions: [url]http://www.programmersheaven.com/mb/CandCPP/315619/315619/how-to-pass-a-two-dimensional-array-by-ref/[/url] I would opt for the "use a vector of vectors rather than a 2D array" option. David | |
Re: Your DUTY class does not have a getName() function, hence you have to first get the instance of a class (a FLATMATE) which does have a getName() function (WashDutyList.at(j)).getResident()) and then call getName() on it. | |
Re: You cannot replace a line in a plain text file like this. You'd have to either 1) Read the whole file into memory, replace the line in memory, then rewrite the whole file or 2) Use an actual database (SQL or similar) | |
Re: Here is my initial feedback: 1) You should make variable names and class names as descriptive as possible. What is a "Pred"? What is 'vPred'? What is 'x' and 'y'? Why are they strings? 2) (1) is also aided significantly by the heavy use of comments! 3) What is your … | |
Re: I have a few comments/suggestions. 1) [icode]user_guess[/icode] is unused. You should setup your compiler to tell you about this - mine gave me a warning when I compiled your code. 2) There is no reason to use defines here - it is bad "c++ style". At the least, change the … | |
Re: I would actually imagine they are assuming the computations take 0 time. So you just need to make a function wait(2) that pauses for 2 seconds. | |
Re: If possible, please post a reasonable compilable length of code using code tags. You will likely get many more responses if people can look at your code directly in the browser versus having to download and open it. | |
Re: I agree with Kontained. To generate the numbers ("call" them in Bingo), I would make a vector of all possible numbers and then shuffle it: [url]http://programmingexamples.net/index.php?title=CPP/STL/RandomShuffle[/url] | |
I have a line like this: [code] <EMBED SRC="ObtainingAndBuilding_Linux.swf" WIDTH=200 HEIGHT=300</EMBED> [/code] that I want to replace 200 and 300 by the browser window width and height. I found some code like this which correctly gets and displays the width and height: [code] <HTML> <head> <script> function showWH(){ if (document.all){ … |
The End.