- Upvotes Received
- 3
- Posts with Upvotes
- 3
- Upvoting Members
- 3
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
19 Posted Topics
I'm trying to simulate particle attraction and motion. Given two particles with 0 velocity at distance X, the acceleration due to attraction is such that the sum of acceleration must be equal to the sum of the deceleration over the same time after the particles pass causing the velocity to … | |
I have a parser that builds a list of variables and a list of expressions. I put those into a block expression and compile ... [CODE] var blk = Expression.Convert(Expression.Block(Parser.m_Vars, Parser.m_Expr),typeof(CVar)); var expr = Expression.Lambda<Func<CVar>>(blk); var result = ""; try { var actionX = expr.Compile(); result = actionX(); } [/CODE] … | |
Re: What it is telling you is it can't find a matching function to construct the base class 'account'. If there is not one, change your checkingAccount constructor to call the correct account constructor... [CODE] checkingAccount::checkingAccount(string inType) :account(inType) { }; [/CODE] | |
Re: Insert at line 123 ... [CODE] else { printf("\nduplicate or unknown character\n"); } [/CODE] and see what you get. | |
Re: Just a few things to clear up. 1) How are existing new lines to be handled? If they should be ignored then line 35 should not output if c == EOL. 2) In the skip space loop you will skip new lines (isspace('\n') == true). So your test to restart … | |
Re: Save the result of the string compare so you wont do it twice. Then just increment a counter. [CODE] int seq_Search(char array[][MAXSIZE], int end, char *key) { int mid; int first = 0; int last = end; int cmp; while(first <= last){ mid = (first + last) / 2; cmp … | |
Re: It works for both cases here. I didn't see any glaring problems that relate to your issue. At line 97 I think you intended something else ... [CODE] for(ctr = 0; ctr < strlen(n); ctr++) sum += (int)n[ctr]; // [ctr]<--- you want to sum the chars ? [/CODE] I'll look … | |
Re: Just cast the return, time_t is equivalent to int for 32 bit OS. [CODE] return (int) MTIME; [/CODE] To fix the printf warning include stdio.h | |
Re: Well it looks like that's what it's supposed to do. It should print the hex representation of the floating point number 4.379. But I don't see how it will compile and it will only print 3 of the 4 hex bytes. | |
Re: [QUOTE=Hiroshe;903618]Still room for inprovement, but I got it working a reasonalble speed.. I think I kinda solved this thread on my own, but if there are any other suggestion's, I'm still interested in making my code faster.[/QUOTE] The first improvement I found was that you don't need to regenerate all … | |
Re: The code as is should work right the first time. If you are reading multiple lines it will start putting leading spaces in because start is not reset for the next one. | |
Re: In the case of zero sized array, it was generally used as an easy way to index into a variable sized buffer ... [CODE] struct Header { DWORD dwMagic; DWORD dwSize; BYTE data[]; }; void MyFunction() { Header *pHdr = (Header *)buffer; Read(buffer, MAX_SIZE); switch(pHdr->dwMagic) { case M_TAG('R','I','F','F') : HandleRIFF(pHdr->data,pHdr->dwSize); … | |
Re: If speed is not critical use a recursive function. [CODE] GenNextMove(int depth) { if(depth == nMaxMove) { nTotalPos++; return; } for(i = 0;i<nMoves;i++) { GenNextMove(depth+1); } } main(...) { GenNextMove(0); } [/CODE] You can pass the current position as well to store in a final positions array when MaxMoves is … | |
Re: [QUOTE=vmanes;1013734] Typical loop usage: [code] int arr[10][5]; int r, c; for( r = 0; i < 10; r++ ) for( c = 0; c < 6; c++ ) // <--- typo ? //do something with arr[r][c] [/code] [/QUOTE] I'm assuming that was a typo? @Triztian: Array elements follow each other … | |
Re: Also it would be a good idea to save strlen(string) and instead of doing strlen in the for loop. [CODE] int iLen = strlen(string); for(i = 0; i < iLen; i++) ... [/CODE] Not only to save operations, but in the non- tempString version you could actually get the wrong … | |
Re: You can do this without the 'if' checks and with 2 nested for loops. Break your problem up to it's smallest pieces and choose a path that solves the pieces with the least redundancy. Smallest piece - put '*' in array at correct place... [CODE] "--*--" ar[0][cnt/2] = '*' [/CODE] … | |
Re: The stringSend member should not be part of the structure you send. It is just a 4 byte ptr that will be meaningless to the receiver. Thus when you send it will be sizeof(struct) - sizeof(char *) bytes. Then you send the payloadLength bytes at stringSend; When you receive do … | |
Im calling a function in a 3rd party dll. Somewhere down the line it hits an access violation (0xC0000005). I wrapped the call in a try/catch but it never catches and the runtime pops up the old Unhandled Exception. This call is several calls deep in my code so I … | |
Hi, I wonder if anyone has seen a solution for a similar problem or can think of a better solution than this. I initially tried to use Floyd-Warshall with a MAX function instead of MIN but the result was not as expected. If one could make that work it would … |
The End.