Posts
 
Reputation
Joined
Last Seen
Ranked #1K
Strength to Increase Rep
+4
Strength to Decrease Rep
-1
100% Quality Score
Upvotes Received
16
Posts with Upvotes
11
Upvoting Members
11
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
10 Commented Posts
0 Endorsements
Ranked #864
~15.1K People Reached
Favorite Tags
Member Avatar for Ricky65

Just extract the bytes from the string and then append the file contents. One way to do that is to create another vector and copy the header and contents there: [CODE]#include <cstdio> #include <cstdlib> #include <string> #include <vector> #include <algorithm> #include <iostream> #include <iomanip> void HexDump( char ch ) { …

Member Avatar for bakri
0
1K
Member Avatar for pandaEater

[QUOTE=firstPerson;1353174]Ok and the code OP showed should be similarly proved right? Like so : Summation from i = 1 to N Summation from j = x, where x = 2^i Thus N * Summation from j = x, where x = 2^i = {1,2,4,8,16...} If you look on [URL="http://en.wikipedia.org/wiki/Summation"]wiki_summation[/URL]. In …

Member Avatar for gashtio
0
378
Member Avatar for frank754

The User-agent field is mainly used for formatting the response accordingly (e.g. for mobile phones) and shouldn't result in an error code(4xx). The 405 you're getting means that the method used in the request (POST) is not allowed. If you examine the headers of the response from google.com you'll see …

Member Avatar for gashtio
0
161
Member Avatar for destruct0

You can use [iCODE]BinaryFormatter[/iCODE]'s [iCODE]Serialize[/iCODE] and [iCODE]Deserialize[/iCODE] methods instead of [iCODE]StreamWriter[/iCODE]/[iCODE]StreamReader[/iCODE]. Here's a little sample I wrote (with no error checking at all): Receiver [CODE]static void Main(string[] args) { TcpListener listener = new TcpListener(IPAddress.Any, 5005); listener.Start(); Console.WriteLine("Server started."); Socket client = listener.AcceptSocket(); Console.WriteLine("Accepted client {0}.\n", client.RemoteEndPoint); List<string> l = null; …

Member Avatar for destruct0
0
2K
Member Avatar for ds.eickhoff

I didn't test it, but here are the problems I saw: First, your bounds check is incorrect - [iCODE]if((row == size) || (row < 0) || (column > size) || (column < 0))[/iCODE] should be [iCODE]if((row >= size) || (row < 0) || (column >= size) || (column < 0))[/iCODE] …

Member Avatar for gashtio
0
178
Member Avatar for daviddoria

[QUOTE=daviddoria;1346490]I see... why do they provide these make_heap functions then?[/QUOTE] Because you might have an existing collection that you want to turn into a heap in-place, instead of duplicating the elements using [iCODE]push[/iCODE]es into a [iCODE]priority_queue[/iCODE]. Or, if you want to guarantee a O(nlogn) bound of a sort, you can …

Member Avatar for Narue
0
102
Member Avatar for myk45
Re: CRC

There's a newline between 1010101a and 1a, which has a different character code from 'a', so you get an additional [iCODE]true[/iCODE] in your vector.

Member Avatar for myk45
0
135
Member Avatar for muze

Use [iCODE]_tprintf( TEXT("%s"), lpszDevName );[/iCODE] instead. You'll also have to [iCODE]#include <tchar.h>[/iCODE].

Member Avatar for muze
0
157
Member Avatar for ToRtUgOxX

Here's some code that issues a GET request and writes the response to file. I tested it on Windows only, but it should work on Linux, too. It doesn't exactly "fill the search box, and click submit button", but should be enough to get you started. [code] #ifdef WIN32 #define …

Member Avatar for gashtio
0
415
Member Avatar for hanvyj

The problem lies in the loop filling the bitmap data. You can make a simple calculation of how many bytes you are writing - 3 each iteration, width*height/3 iterations - a total of width*height bytes, not pixels. Essentially, you're writing to every third pixel, hence the diagonal lines. To correct …

Member Avatar for hanvyj
0
210
Member Avatar for VBNick

This code should only hang if you lift the key while the worker thread is executing this: [code] while(WaitForSingleObject(input->run, 0) != WAIT_OBJECT_0) { SetWindowTextA(input->hWnd, "Hello"); Sleep(500); SetWindowTextA(input->hWnd, "Goodbye"); [/code] but not this: [code] Sleep(500); } [/code] The problem is that [iCODE]SetWindowText[/iCODE] actually sends WM_SETTEXT (sends, not posts) so it blocks …

Member Avatar for VBNick
0
100
Member Avatar for Nexgr

You can do fine using the STL's priority queue with some modification of that pseudocode - namely always inserting the neighbours in the PQ, unless they are in the closed set. This will result in having duplicate nodes (with different f/g costs) in the PQ, so each time you pop …

Member Avatar for Nexgr
0
163
Member Avatar for nbaztec

You can use this (and probably add some error checking): [CODE] // Gets the local IP address // IPv4 address and little-endian machine are assumed #include <cstdio> #include <ws2tcpip.h> #pragma comment(lib, "ws2_32.lib") int main() { WSADATA wsadata; WSAStartup( MAKEWORD(2, 2), &wsadata ); char buffer[256]; struct addrinfo * result; struct addrinfo …

Member Avatar for gashtio
0
203
Member Avatar for dansnyderECE

You are taking the address of a [iCODE]char[/iCODE] pointer to get string and taking the address of a [iCODE]char[/iCODE] to get the character itself - these are the problems with [icode]cout << "Characters:" << &temp << endl[/icode] and [ICODE]while(&temp[i]!=0)[/ICODE]; In the former, you're taking the address of the pointer [iCODE]temp[/iCODE], …

Member Avatar for gashtio
0
176
Member Avatar for ayan2587

As firstPerson said, the last digits can be obtained by modular exponentiation. Getting the first digits requires some mathematical trickery, but nothing too special. I've commented the code so it shouldn't be hard to understand. [CODE]#include <cstdio> #include <cmath> typedef unsigned int UINT; typedef unsigned long long ULL; //-------------------------------------------------------------------------------------- // …

Member Avatar for ayan2587
0
176
Member Avatar for Graphix

You're probably missing [I]comdlg32.lib[/I] in your linker settings. By the way, the Common File Dialog API has been superseded by the [URL="http://msdn.microsoft.com/en-us/library/bb776913(VS.85).aspx"]Common Item Dialog API[/URL].

Member Avatar for Graphix
0
2K
Member Avatar for Graphix

You have to process the WM_CTLCOLORSTATIC message in the parent window (WM_CTLCOLOREDIT should you change the edit box style so it is neither disabled nor read-only). It is sent by the control to its parent before being drawn, passing its device context in the WPARAM, so you can change text/background …

Member Avatar for gashtio
0
4K
Member Avatar for invisal

It's always nice to see people posting tutorials, but I have to disagree with both pieces you posted. You need not do any of these things, because that's the compiler's job - making the machine code optimal. Precalculating constants and rearranging expressions in weird ways only makes code hard to …

Member Avatar for invisal
3
202
Member Avatar for Ricky65

HTTP headers must end with a CR/LF line, so you should add [ICODE]sprintf(Get_Request, "%s\r\n", Get_Request);[/ICODE] at the end to get it working. Also, when [ICODE]recv()[/ICODE]-ing, you shouldn't use [ICODE]strlen(Response)[/ICODE] as the length argument, since your buffer isn't initialized, so [ICODE]strlen[/ICODE] will pretty much return random numbers. Instead, use [ICODE]sizeof(Response) - …

Member Avatar for Ricky65
0
361
Member Avatar for donaldw

You can call [ICODE]ISpVoice::Speak[/ICODE] asynchronously and then use the [ICODE]ISpVoice::WaitUntilDone[/ICODE] method, which does exactly what you want. [CODE]pVoice->Speak( szText, SPF_ASYNC, NULL ); pVoice->WaitUntilDone( 3000 ); // 3 seconds[/CODE]

Member Avatar for donaldw
0
181
Member Avatar for DarkT

The problem lies here [icode]HashTable = new (nothrow) ListSet [size];[/icode]. [i]Short explanation:[/i] You are allocating an array of [icode]ListSet[/icode] [b]objects[/b] and handing the returned pointer to a [icode]Set *[/icode]. This is not how inheritance works - you should allocate an array of [icode]Set[/icode] [b]pointers[/b] instead, and then allocate a [icode]ListSet[/icode] …

Member Avatar for DarkT
0
2K
Member Avatar for ashkash

Assuming 2^n takes O(1) time, the complexity is O(log* n), that is, the [URL="http://en.wikipedia.org/wiki/Iterated_logarithm"]iterated logarithm of n[/URL].

Member Avatar for invisal
0
93
Member Avatar for inisca

You can use one of the [ICODE]Marshal::StringToHGlobalAnsi/Auto/Uni[/ICODE] methods to copy the string into unmanaged memory, and then clean up with[ICODE] Marshal::FreeHGlobal[/ICODE] when you're done. There's an example [URL="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.stringtohglobalansi.aspx"]here[/URL] that does exactly that.

Member Avatar for jonsca
0
132
Member Avatar for Lukezzz

This happens because [icode]StreamReader::ReadLine[/icode] returns [icode]nullptr[/icode] when the end of stream is reached (which is the case when reading an empty file). That means that on line 8 of your code [icode]line[/icode] is now [icode]nullptr[/icode], and not the initial empty string. Since they do not compare equal to each other, …

Member Avatar for Lukezzz
0
106
Member Avatar for vbx_wx

The [icode]recv()[/icode] function will return <= 0 if either a socket error occurs or the socket has been closed on the server side. If none of these are true, it will just block, waiting for data. So, I'm guessing your problem is that you didn't close the socket. If, for …

Member Avatar for gashtio
0
123
Member Avatar for HealBrains

What is the desired direction of the ray? If it is +Z, just specify (0,0,1) for rayDirection. Currently you're generating something rather strange - a direction parallel to the line, defined by the points (0,0,0) and (shotOrigin._41, 0, shotOrigin._43) from line 4 of your code. Otherwise, the conversion from world …

Member Avatar for HealBrains
0
205
Member Avatar for sexyzebra19

There are quite a few things wrong :). - All the "mdim_ = mdim_;" stuff is useless. - In the Matrix(int cols) constructor, mdim_ remains uninitialized and you're getting a crash - you should set it to cols. - The SetElement() function is incorrect, it should read: [code=c++]void Matrix::SetElement(int m, …

Member Avatar for sexyzebra19
0
98