- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 16
- Posts with Upvotes
- 16
- Upvoting Members
- 10
- Downvotes Received
- 2
- Posts with Downvotes
- 2
- Downvoting Members
- 1
186 Posted Topics
Re: You have many many errors in your code. Are there any errors in particular that you're having trouble understanding? you don't need the line: BloodDonor bldDnr; or any reference to bldDnr your enum bloodType tries to use invalid characters as variable/enumeration names. Try using allowable names. setting the default address … | |
Re: If you're just displaying the reversed thing to the screen, there is no need to store any numbers in any arrays. Each call to the function will print out a single digit (the digit of number in the units place). If the number is more than 9, the function will … | |
Re: [QUOTE=daviddoria;587847]I would like to take a screenshot of a region of my screen programmatically (so I can do it every time through a loop, for example.) Does anyone know how to do this? I guess it would involve the win32api - I've not used this before so any hints would … | |
Hi all, Does anyone know how to quickly (i.e. O(log n) time) insert items into a sorted list? I'd prefer an existing working function if available; I didn't see any appropriate ones in boost or stl. Some background: I'd like to keep a constant sized sorted list, and insert items … | |
Hi all, I'm writing a simple application in C# but I'm having an annoying ArgumentOutOfRangeException thrown by Invoke() saying "Text length must be less than 64 characters long.". Is this usual that strings passed through delegates have to be shorter than 64 characters? What's the usual neat way around it? … | |
Hi all, I have an application with a ListView of remote files. I'm trying to implement a drag-drop of these files between my application and e.g. windows explorer. I have an object implementing IDataObject used for the DragDrop operation and the files are passed in a string[]. The problem is … | |
Re: [code] int number = rand() % N; // gives you a random number from 0..(N-1) number += L; // the number between L..(L+N-1) [/code] So if you know your upper and lower limits, you can work out what N & L should be. | |
Re: Make sure you store the number of rows & cols of each matrix. This may be easier if you put them in a matrix class or struct. e.g. [code=CPP] struct Matrix{ float *data; int rows, cols; float *operator[](int row){ return &data[row*cols]; } }; Matrix A; // read maxRows/cols from file … | |
Re: To check if an iterator has passed over all elements compare it to the end (for iterators) or rend (for reverse iterators). [code] string::reverse_iterator rit = st.rbegin(); string::iterator it = st.begin(); for(; rit != st.rend() && it != st.end(); rit++, it++){ // do comparisons here [/code] | |
Re: Here's some code to help you get started with the C++ syntax for writing a matrix class. I've put the matrix sum function in for you - you'll have to write the other matrix functions. This code compiles and runs in Dev-c++4.9.9.2. As Rashakil Fol said, you may want to … | |
Re: [quote]I must take that pointer or address (I can't remember which it is) and convert it to a string[/quote]I think you're mixed up a bit (or maybe I am). I'm assuming GetScore returns true if the user enters a valid number. You've got this correct. I'm also assuming that GetScore … | |
Re: I've used the old Ericsson mobiles to read contents of SIM cards and to send/read SMSs. The commands are sent to the mobile using your serial port at 9600,n,8,1 - you will need to convert the RS232 level (+/- 10 volts) to TTL level (0-5 volts) - can use MAX232 … | |
Re: [QUOTE=ojung;755253] cout<<"Enter word to search \n"; cin>>word[i];[/quote] that should be [code]cin >> word;[/code], because word[i] is a char, and word is a char array [quote] while(dict.getline(text,300)) { if(word[j]!=text[j]) { [/QUOTE] Likewise this should be [code]... if(string(text).find(word) != string::npos){ ...[/code], otherwise you are comparing the first character only, and not the … | |
Re: I think by 'infinite array' you are meaning something like 'sparse array' - where only a few elements over a large range are non-zero. You can use a std::map<int, int> for your array of ints using an integer index. [code] map<int, int> array; array[20] = 5; array[51] = 6; cout … | |
Re: Here's the code in C#, shouldn't be hard to see what's going on: [url]http://www.codeproject.com/KB/recipes/ShortestPathCalculation.aspx[/url] There are plenty of other resources referenced from: http://en.wikipedia.org/wiki/Dijkstra's_algorithm | |
Re: As ArkM stated, you don't need to return an integer value as a complex<double> (although you can if it pleases you, of course). I found the condition in the while() loop a little strange, so I changed it to: [QUOTE=doll parts;727072][CODE] while ((abs(f(x)) > error) && (n < nmax + … | |
Hi, I have written a v. small VB.NET program that spawns "cmd.exe" using Process, redirects stdin/out/err; works OK so far. Does anyone know how to get : * the details about the process currently running (if any) under cmd.exe (like how the command shell displays 'c:\windows\system32\cmd.exe - dir /s/b' when … | |
Re: How about you use code tags and post code that can be compiled. There are easier ways to get file listings by using the OS list functions & _popen(). The output can be read using fread(). In windows: "dir /s/b ", in Linux: you could try "ls -R -l ". | |
Re: [QUOTE=Comatose;766215]How can you dynamically allocate memory on the heap using a reference?[/QUOTE] [code]int &x = *new int();[/code] This should do it. | |
Re: I have an dumb idea, what about an operation like convolving the test string with itself; i.e. doing a sliding comparision of the elements of the test string with the reversed-test-string. The longest consecutive string of matching elements is the longest palindrome. Here's the code: [code=cpp]// do some convolution string … | |
Re: or you could make a card class, e.g. [code=cpp]#include <iostream> #include <string> using namespace std; class Card{ private: int cardNumber; // 1 - 52 public: Card(int _cardNumber = 1) : cardNumber(_cardNumber) {} void setCardNumber(int _cardNumber){ cardNumber = _cardNumber; } void setCard(int cardType, int suitType){ // cardType e {1..13}, suitType e … | |
Re: assuming str is of type 'string', str[i] is of type 'char'. chars will be considered negative whenever the top bit is set. It's not an issue if you are bitwise ORing, as you will get the correct result. If it annoys you, feel free to cast to unsigned char, as … | |
Re: sprintf expects a char* as the first parameter; it is where it will store the output, as a string of characters. I don't know what you actually want to do, but if you want to see that it's working, try the following lines (instead of the sprintf lines above): [code=c] … | |
Re: [QUOTE=cam875;742372] object's new x,y position should display as (0.5,0.5) but everytime i run it with those values i get (0,1) and I am not sure what is wrong. [/quote] Not quite. Distance of 1 from (0,0) heading 45^ will be (0.707, 0.707) [QUOTE=cam875;742372][code=cpp] if (heading > 0 && heading < … | |
Re: then start at a value 1 more than the highest in the dB, if you wish to use incrementing type indexes. Or you could use the number of microseconds since (e.g.) 12:00am jan 1900 UTC as your 'unique number'. | |
Re: [QUOTE=Ancient Dragon;742495]>>a = c; That's illegal.[/QUOTE] Have you tried compiling it? | |
Hi. I have written a small test socket program that uses a background thread that accepts tcp connections and adds them to a connection list that is accessed by main(). When a connection is opened, then later closed, recv() is called (see line highlighted in code below), which throws an … | |
Re: For hi-res timers, you may want to have a look at the following (100us timer period): [url]http://www.codeproject.com/KB/system/RealTimeModule.aspx[/url] [QUOTE=Arctic wolf;736190]I need a real time clock to generate accurate PWM for a robot...[/QUOTE] What's the frequency of the PWM? Are you interfacing to RC servos? | |
Re: [QUOTE=LincolnGurl;736380]From your rather elementary diagnosis of the VC++ debug code...[/quote] not so friendly hey? [QUOTE=LincolnGurl;736380]String1("Hello"); <- Familiar syntax, but length processed during run-time construction. OR String1(_MyMacro("Hello")); <- Reasonably familiar syntax, but length processed via compile-time construction and immediately available at run-time. [/quote] So what do you actually want? The length … | |
Re: [QUOTE=CPPRULZ;731760]Our 16 by 16 array of bits now becomes a 2 by 16 array of bytes. [[I]Why isn't it a 2 by 2 array?[/I]] [/QUOTE] A byte is made up of 8 bits. Therefore a row can contain the 16 bits in 2 bytes. There are 16 rows, hence 2 … | |
Re: [QUOTE=VernonDozier;731746]When in doubt, write a program! It's faster and more accurate than research.[/quote] ummm.... google seems to quickly turn up a bunch of results for this question, e.g. [url]http://www.cppreference.com/wiki/operator_precedence[/url] You're right, division/multiplication/modulus all have equal precedence. [QUOTE=VernonDozier;731746] ... It's one of the reasons I never liked "PEMDAS". If all you … | |
Re: include the dll.h header, and not the project3.dll file. Make an import library - the .lib file, should be an option in your compiler/linker link the .lib file into your project. The program will know how to access the .dll file from the details stored in the .lib file. | |
Re: I wrote an equation parser a few years back, don't have it on me, but I'll try to dig it up for you. I think the idea I used was to pass through the equation string a few times - the first time assigns a numerical priority to each operator … ![]() | |
Re: Dunno from the code you posted. Was the data even written properly in the first place? Did you open the fstream in binary mode? | |
Re: yes. You'll be using [icode]travel ** travelArray[/icode] That said, your assignment line will of course be [icode]travelArray[index] = &aTrip;[/icode] I noticed you check if index <= size. If the array declared has size elements, this will be a problem; if the array declared has size+1 elements, then it is not … | |
Re: [QUOTE=mrrko;710457][CODE]double fib(int iter) { while (iter >= 0) { while (iter >= 0) { fib(0) = sizeCrudPopulation; } while (iter >= 1) { fib(1) = sizeCrudPopulation; } while (iter >= 2) fib(iter) = (fib(iter - 1) + fib(iter - 2)); } } [/CODE][/QUOTE] Most of your code (not the above … | |
Re: Line 20 should be moved to after line 24: you want to let the user enter the search value before you call the search function. line 86: remove this line - the break statement would quit the loop; before you get to report the location the seqOrderedSearch function should return … | |
Re: This thread seems to be predecessor to [url]http://www.daniweb.com/forums/thread150474.html[/url] | |
Re: What [QUOTE=egolovin;709894]can someone look at this? in theory it should work but i cant figure it out thanks in advance [CODE=CPP] if (test==1)[/CODE][/QUOTE] That line should be [icode] if (test == '1')[/icode] 1 is different to '1' (character code 49, as Rhohitman said). Also, for powers of 2 you don't … | |
Re: setw works fine without the need for '\t'. Note that setw is required prior to each item to be formatted. e.g. [icode] cout << left << setw(12) << "item1" << setw(12) << "item2" << endl;[/icode] | |
Re: I don't think it's in the language. You could use #define square box. You may want to google template typedefs, or check out [url]http://www.gotw.ca/gotw/079.htm[/url] for some solutions. | |
Re: [QUOTE=Freaky_Chris;704970]So you have 2 choice's pay someone...again good luck cause most ppl still won't do this OR DO IT YOURSELF(at least have a good go)[/QUOTE] What?? I know a lot of people who will write code for money (myself included). I believe it's fairly standard practice; even a respectable career … | |
Re: Windows CE has APIs for this kind of thing. The prototype for the function is [code]BOOL CopyFile(LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName, BOOL bFailIfExists); [/code]. Go to MSDN if you need info on return values, etc. try [url]http://msdn.microsoft.com/en-us/library/ms959899.aspx[/url] | |
Re: Obviously recursion would enable a simpler/cleaner approach, if it were allowed. There is no mention of need for speed/efficiency in the problem statement, so it may be perfectly valid to just use a dirty brute-force method: [code=CPP]#include <iostream> #include <iomanip> #include <sstream> using namespace std; bool numberValid(int v, int len){ … | |
Re: Do you not know how to use google (or any other search engine)? You will find more than you need if you actually try looking for it. Try [url]http://en.wikipedia.org/wiki/Global_variable[/url] | |
Re: I'm pretty sure there's oodles of freely available guides available to tell you how to use openCV. Try [url]http://www.google.com/search?hl=en&rls=com.microsoft%3Aen-au&q=opencv+visual-studio[/url] Failing that, I found the following works for me: Basically what you have to do is set up your project to include the following files: "c:/Program Files/OpenCV/lib/cv.lib" "c:/Program Files/OpenCV/lib/cvaux.lib" "c:/Program Files/OpenCV/lib/cvcam.lib" … | |
Re: I can't see any reason why you don't just split all the fields, assign: [code=pseudocode] field[] = split(line, " ") genre = field[0] category = field[1] title = field[2] n = field.count()-1 for i = 3 to n-1 title = title + " " + field[i] next i time = … | |
Re: The count method is incorrect; there is no terminating condition, hence the stack overflow. [icode](map[valueRow][valueCol + 1] != 'b' || map[valueRow][valueCol + 1] != 'v')[/icode] will always be true, as the map element cannot be equal to both 'b' and 'v'. You should also check the map indices you are … | |
Re: use getline to read the inputSentence from cin. This will stop reading when it gets the enter key. put the entered sentence into a stringstream. read the words out of the stringstream while there are words to read. [code=cpp] #include<iostream> #include<string> #include <sstream> using namespace std; const string chicken( "chicken" … |
The End.