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