389 Posted Topics
Re: Ignoring the return issue for the moment... Sales will fall right through the loop! double sales = 0.0; while (sales != 0) You set it to zero, then loop while not zero! | |
Re: You converted your ASCII numberical value to a Floating-Point value with... [CODE=C] floatValue = atof(buffer); // this returns the same value!!! [/CODE] So just multiply the result by two! [CODE=C] floatValue *= 2.0f; [/CODE] Or did I miss what you were really asking for? | |
Re: Were you trying to do a Null terminator check? if(num == 0 && !(buf == "0")) { vs if(num == 0 || !*buf) { | |
Re: I'm not sure what you're asking for. You can get/set the user value associated with a list/combo item. You can add and remove items. | |
Re: You're trying to test a numerical value for an ASCII character! if(!isdigit(nCelsius)) isdigit( char ) thus "9834" first character '9' But its encoded as 9834 an integer. What they said! Simultaneous posting! | |
Re: Just a thought [CODE] const float Y1 = (2 * SQRT2) / 7 - 1 / 7; const float Y2 = (4 * SQRT2) / 7 - 2 / 7; const float Y3 = SQRT2 / 2; const float Y4 = (3 * SQRT2) / 7 + 2 / 7; … | |
Re: You're equating, not comparing.. if(cDoContinue = 'n'){ should be if(cDoContinue == 'n'){ better yet if( tolower(cDoContinue) == 'n'){ | |
Re: A file is not elastic so two ways. 1) copy file A to file B but skip over the parts of file A you don't want copied! 2) invalidate the data! Write a 'bad' character code over fields in the data you don't like. The file size will remain the … | |
Re: You had x items y count per line! Please write your code and post for our review! [CODE] while x > 0 n = min( x, y ) x -= n while (n) print the rnd # end print the end of line. end [/CODE] | |
Re: Put a counter on the interrupt and pre-clear, then after a short while, examine the counter and see if it is non zero! | |
Re: There are many sort algorithms in existance. The simplest but slowest is you have all your values in an array and you know the count of the array. [CODE] swap = true while swap is true swap = false for index = 0 to cnt-1 step 1 if ary[index] > … | |
Re: You should definitely split the work load between threads, Render thread should ONLY handle rendering, but the output of the physics and other threads that alter the data the rendering thread uses should be in a request form. Data is kept separate but a shadow copy of the data the … | |
Re: I see several problems. You would have found them immediately if you had typedef enum's but here goes. You enter types 1,2,3 but you submit them for processing as type artichokes, artichokes, artichokes. Also your data entry is confusing. You should enter weight and product type, pass it as such, … | |
Re: Ditto as to what CSurfer said. Also you need an exist but empty file handler! Meaning file exists but empty, thus no data read thus BOOM! Divide by zero! You need a zero case handler! I'd also recommend to write clean code! Something teachers don't teach from the old C … | |
Re: You have several problems. But first, was it requested that you enter the maximum number of characters or did you decide that your self? If yourself then merely use a large static buffer and watch when you're approaching the end of buffer. And set a certain keyboard character to be … | |
Re: untested but here... [CODE] int main() { char tmp_array[100]; const char* seq = "+1236,,..,,actgn+3ACT-4CCCC"; printf("%s\n",seq); while (*seq) { // pre-scan for +- if (*seq != '-' && *seq != '+') { seq++; continue; } char *p = tmparray; *p++ = *seq++; while (*seq) { if ((*seq < '0') || ('9' … | |
Re: Open the file with the sharing flag set will give you some flexibility. If you want your program to delete a file clean due to corruption, etc. you can use one of the following! Simple CRun time library call. [CODE=C] #include <io.h> remove( "HowdyDoody.txt" ); [/CODE] And since you're using … | |
Re: I'd recommend a container class where you pass two axis but gets resolved to a single array allocation. This is only one example of how to solve this! [CODE] class IntArray { private: int *pInt; unsigned int nWidth; unsigned int nHeight; public: IntArray( unsigned int w, unsigned int h ); … | |
Re: You have to parse each field and check to see if its legitimate. Also check the day number to number of days in that month. And double check if its a leap year or not. You could parse and convert to Julian and store as a 32-bit number. You may … | |
Re: Rather then do that, how about going with Worker Threads and I/O completion ports! Very lightweight and you can associate a socket with a user value so since few threads are handling a multitude of sockets, the user value (an index) can be used to connect the traffic to the … | |
Re: You have to perform analysis on the data pertinent to an individual after you've processed everyone in the file which means you need to store the information. Run the list once to find out how many there are! rewind create structure array to store the students. One structure each student. … | |
Re: Exactly as csurfer said. You're trying to traverse your linked list but you're also overwriting each node from the file read thus invalidating your pointer! Exit your functions upon errors. Don't keep trying to load or save data when you have no file handle! | |
Re: BOOM? Your indexing count is 10. How big are your input and output arrays? | |
Re: Your instructions said print, but you're writing results to a file! Add code tags, clean up, and re-read your instructions. | |
Re: Can you add more then that snippet. And add comments! That 80x86 assembler you're using is camouflaging the assembly code making it harder to read due to its abstraction methodology. | |
Re: You're reseting the processor so you come up in real mode, you set your CS and DS segment registers and the first thing you do is use the stack in your video interrupt call! Shouldn't you be setting up your stack as well before you use it? (Just a thought!) … | |
Re: Grade conversion should be easy. iteration enumeration So each enumeration A through F you can assign to to standard scoring levels? F=0, D=1, C=2, B=3, A=4 And GPA is merely the average. @sum( 0...N-1) / N But you need to fill in all your class requirements first, take a pass … | |
Re: You are talking about floating point. Dependent upon the data format typically IEEE 32-bit SPFP Single-Precision Floating-Point 64-bit DPFP Double-Precision Floating-Point 80-bit Double-Extended Precision Floating-Point there are three components. A sign bit, typically the MSB. The Exponent and the Mantissa. So 1.0 in 32-bit using IEEE would be 0x3f800000 -1.0 … | |
Re: So why aren't you using an empty block of stack and filling it with primes so then you only need to divide by earlier resolved primes instead of the entire set of numbers? My mind is a bit tired, but as a rule you should always heavily comment your code. … | |
Re: [CODE] char *extract(int *pos, char *array) static char output[11] = {0}; int max = (*pos) + 10, count = 0; // Need a terminator detection or will overrun the buffer // on last 10 character run if fewer then 10 chars! while(( 0 != array[*pos] ) && (*pos < max)) … | |
Re: I haven't looked at your code but when you connected to your friends computer. Were they at your location or somewhere else. If somewhere else is your friends computer acting as the host on a static or dynamic IP. If dynamic then you're out of luck. If static then you … | |
Re: Here's a leg up... Technically [CODE] char ary[] = "Never go down to the whithering woods. The creatures who live there are up to no good. The gnomes are nasty and the trolls are hairy, and the creatures who live there are scary"; [/CODE] That is not a string. That … | |
Re: Use stricmp() Same as strcmp except it's caseless! Though I'd recommend strlwr or strupr to convert to lower and upper case but do a strncmp so that you're only comparing the first 3 letters. That way abbreviation can be used and a match will still work! To save a running … | |
Re: Missing your fact initialization! Also in your code, you need the entire function because a is missing, etc. And why the second loop if it is based upon the outer loop? [CODE] for ( int x = 0; x <= 10; x = x + 1) { int fact = … | |
Re: Found your problem on-line. We are to write a program that calculates and displays the probability of 0 to 10 planes attempting to land in any minute period at an airport during peak arrival times. We are supposed to use Poisson probability function. Your answer is posted elsewhere with a … | |
Re: [B]And why are you storing your return address into your address of average? Also in odd_lp you're storing the list entry to the minimum $a2 not the median $a3 as your comment says [/B] [CODE] [B] sw $t2, ($a2) Save minimum #median sw $ra, 8($sp) Save return address?[/B] sw $fp, … | |
Re: Write your algorithm in C first. Once working then in assembly. C is close to assembly without the time consumption necessary to get your program working. Once you have your flow down, then do the assembly. Post your C and your latest attempt at assembly (since you said you've been … | |
Re: ALWAYS write your function in a highe level language first. Get the algorithms functioning properly. THEN write it in assembly code. Then run both functions and compare the results to validate the assembly! So if using C/C++ write your function in pure C first (NOT C++), then take a pass … | |
Re: Removed my post due to C response but it was a Python question! | |
Re: Use a static buffer 256 or so bytes in size. Plenty of room! You can subtract the current add new character position from the buffer base to get your index. Do a modulus operation and advance that many slots by inserting spaces. OR you can have a moving partition. NEXT … | |
Re: What are you trying to do? Also you don't need the second if, just else! And your return is hinky! [CODE] return keep_per_end=keep/2; [/CODE] You need to add white space to your equations to make problems more apparent! [CODE] return keep_per_end = keep / 2; [/CODE] I'm not sure what … | |
Re: "Get a new PSU!" They're cheap!!!! Sorry, I couldn't resist. You will find that the PSU's have mostly non-available components, and they're usually right to the edge of tolerance for cost savings in manufacturing to maximize profits. The cap didn't blow because it felt like it. Typically the circuits being … | |
Re: Look for something not properly initialized! Singlestep in the debugger and see if data contains expected values. Other then that, the specific problem or code needs to be shown from view to have better insight! | |
Re: You're using a slightly modified graph function as to what is posted from atleast one college on-line. Figure out what you want your scale to be, draw your cross ticks and place your coordinates. You're using max limits each call. You should have something like: [CODE] int cx,cy; main() { … | |
Re: Here you go as in initial pass! But you really need to swap the node links, not the contents of the node. Also you should use a more complex sort then a slow bubble sort! [CODE] void displaysortbyID( void ) { struct school *pre; struct school *move; struct school temp; … | |
Re: When one vectorized their code the idea is to have the three or four components processed side by side. Re-examine your loops as you have a problem. They're all exclusive but some are {0...2} and some are {0...3} for XYZ and XYZW processing. Was that intentional? You haven't shown your … | |
Re: I'm really rusty at Java but this may be an architectural thing. Your topic mentions threading but is this event handlr part of the main threads message pump? If so there's your problem. In windowing system such as Windows the primary thread also handles the graphics. Graphical functions are actually … | |
Re: Arrays and Matrices in C are zero based not 1 based! foo[8] uses indexes {0...7} fob[8][3] uses index [0...7][0...2] | |
Re: Are you using a 32-bit compiler or a 16-bit? If 16-bit then you have a problem! 100000000 is 05f5e100 in hex requiring 32-bits to store. Since you are being signed due to the -1, It seems a Highes score of 32767 would be a more suitable test, IFF you are … | |
Re: You need to pre-initialize your array as you have gaps that aren't set with valid values! {0...47}, {58...64}, {91...96} |
The End.