5,676 Posted Topics
Re: The number of compares in a real bubble sort is the Summation of N, N=0 to n-1. What is 1+2+3...+19? Yours on the other hand is (20\*20)-1 I believe. So you might want to loop up how a real buble sort is defined and correct yours. | |
Re: Finish A and B to output the SPACEs on each line. Then the solution is obvious. | |
Re: Care to give us specifics about the problem? With the explanation you gave, the best answer is "*then you did something wrong*". | |
Re: Probably. Compile as a C program and fix the errors. That's the simplest technique. | |
Re: > and I would like you to answer with a code or function which would work on that compiler... Of course you would. That way you get us to do your work for you. Maybe you should read the Member Rules. | |
Re: > Your indentation could be cleaned up but thats more of a style thing. Actually, your indentation **needs** to be cleaned up. It's a readability thing. You need to be consistent. [See this](http://www.gidnetwork.com/b-38.html) | |
| |
Re: Then your file is not where the program can find it. You are not testing for errors. If the program can't find the file, you ignore the error and read it anyway. Look up the file methods again and add error conditions with worthwhile messages. | |
Re: Output values to see what is happening while the program runs. This can also pinpoint where the error is and what variables have bad values. | |
Re: Possibilities: 1) Change the message color to RED to make it more visible. If you can, change the background of the message to YELLOW to make it pop visually. 2) Add a button that must be pressed to get to the message box to override. Maybe add the hated "*are … | |
Re: Sure. [Try This](http://lmgtfy.com/?q=chat+application+in+c+language) ![]() | |
Re: Can another **Mark** link be added to the top next to the RSS icon? It's rare many of us scroll below half a page. | |
Re: > I thought I could say node1->left = &node2; // left = the address of node 2. > > Is that right? What happened when you tried it? Didn't it work? And what **The Dragon** said is true. Make a pointer named `head` that will point to the first node. … | |
Re: > And atlast there is no ending brace after return 0 (line 68) and no ' ; 'after return 0. [Proper formatting](http://www.gidnetwork.com/b-38.html) would have shown you this error in seconds. | |
Re: I don't understand. The checksum lets you know if the pix are identical. 1) Identical pix have the same checksum. 2) Different pix have different checksums. 3) Different alpha values produce different pix, therefore different checksums. 4) Same alpha values on different pix do not produce same checksum (pix are … | |
Re: > I would have to politely disagree with phorce. Bubblesort would change the indexes of the elements which would prevent you from returning the index of the smallest value (a requirement). Not if you do it correctly. But that's probably beyond the OP scope of knowlwdge. But, sorting is definitely … | |
Re: FYI, `char cPass;` defines one character. There is no way you can cram "*correct*" into one character. | |
Re: You have to somehow label the nodes: 1 Does it have 4 legs? initial (1st) question 21Y Does it purr? 2nd level Yes 31Y Cat 3rd level Yes 31N Dog 3rd level No 22Y Does it swim? 2nd level No 32Y fish 3rd level Yes 32N 3rd level No Something … | |
Re: What happens when you sit at your desk with the code, pencil, and paper and actually follow the program line by line? Writing the variable values as they change? | |
Re: > at the void combine 437 lines and you can't be more specific than that? > also at the part void add which precisely at combine(temp,"") Meaning what? and where? If you notice there are line numbers in your post. They might be useful. | |
![]() | Re: Unfortunately, the one entry on the bar I used to use is missing -- The Favorite Forum links. ![]() |
Re: How much space has been reserved for `char a[] = "Woozle";`?? In total? So will it actually fit into `char c[5];`? How much space for `char b[] = "Heffalump";` So will it actually fit into `char c[5];` too? | |
Re: > So if you changed your code to say (++a)++, your code would work in C++, but not in C. No it won't. Pre- **and** post- incrementing the same value is called undefined behavior, therefore the result may be different on different compilers. The result is ambiguous. [See this](http://c-faq.com/expr/evalorder2.html) | |
Re: **Jason**, Since this is the C forum, why all the C++ suggestions? Steer him correctly to C solutions. | |
Re: Set up an array with the values 1-MAX (array[MAX], MAX being 60) set up a loop with index 1 to 20 get random number from 0 to MAX-index use that number as index into array to store the next number loop from MAX-index to MAX-2 and shuffle all contents down … | |
Re: Look at each character and convert to decimal. Easy peasy. `strtoul()` will take time and testing to understand, you can convert this by hand in 10 minutes. | |
Re: You need to look up what `perror()` actually does. It's not in the wrong place, you're just not using it for the purpose it was intended. Also, don't use `conio.h` and `getch()`. They are non-standard and will cause you headaches when you get to the other 98% of the compilers … | |
Re: With 10 pages of posts here on DaniWeb alone, I'm sure you can find the answer using SEARCH. ![]() | |
Re: Loook up `memcpy()` | |
Re: The correct form is: `(rand() % (max-min+1) + min;` | |
Re: You are generating the random number correctly, just not *using* it correctly. 1) You don't need all that preamble to set up *seconds* and call `srand()`. It's easier (and less confusing) if you simply replace lines 10-12 with `srand(time(NULL))`. Generating *seconds* is obviously confusing you. 2) You *output* a random … | |
![]() | Re: Enter it into a temporary input buffer. Then move it into place in your array. > **np complete:** you can handle such number by linked list. Major overkill. Since the numbers must be kept sequential, why do you need a structure containing and **int** and a **pointer** and all that … |
Re: >You can easily do it yourself. Just look up those hex numbers in any ascii chart >> i dont know how :( Follow his link and figure it out. It's simple. | |
![]() | Re: No, the compiler doesn't know. You told the compiler that the variable was defined somewhere else. That's all the compiler knows. It trusts you. Its when you try to link the declaration with a definition that the linker finds your error. |
Re: Maybe algorithm = formula in this case. | |
Re: > At point 1 string str is "model" How do you know it's not "model\n" or "model "? Neither of those will match "model". For that matter, how do you really know *what* is in **str**? | |
Re: **@np complete** What your idea does is make sure there is a decimal portion to the number. But 5.0 is a valid floating point number. What the OP need to do is basically what **NathanOliver** describes. > I'm new to C++ (bet you guys don't hear that very often!!) Nope. … | |
Re: > This looks like a homework question, and a fairly specific one at that. It looks like something from a programming intro course/tutorial, not an algorithms course. Probably very true, but we have a long-standing guideline that when you simply post requirements with no details, no questions, and no code … ![]() | |
Re: 1) You don't -- this is the **C** forum. 2) Set insert mode off, set the cursor on the **s**, and type. | |
Re: > these small programs doesn't really need inheritence, It does if > The main purpose of this example is to execute inheritance It's how we learn. ![]() | |
| |
Re: The statements are [undefined](http://c-faq.com/expr/evalorder2.html) so the output is not guaranteed to be anything specific. Different compilers may produce different results. | |
Re: **[boilerplate_help_info]** Posting requests for help must be well thought out if you want help quickly and correctly. Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful? Check your post with these checkpoints - what is it *you* … | |
Re: `cout<<'a'+0;`?? You're kidding, right? Standard way to do this is `cout << (int)'a';` | |
Re: A couple other things worth noting: 1: `do{}while((c = fgetc(input)) != '\n');` Why a do-while? Why not just `while((c = fgetc(input)) != '\n');`?? 2: `fseek(input, -1, SEEK_CUR);` Why? Can't you do something better/cleaner than messing with the file pointer? It looks like you're already handling the case without the `fseek()`. … | |
Re: It's what happens when you set up an array like `int array[10]` and use a statement like `array[12] = 23;`. There *is* no `array[12]`. It only goes to `array[9]`. In your case, `"123"` is **4** bytes, not 3. it's '1','2','3','\0'. You forgot about the string indicator. | |
Re: Not a good idea IMO. 1) Many (most) of us won't open attached files or linked images. We certainly won't watch a video. 2) As you pointed out, "*It may require huge database and huge maintainence of daniweb server.*" Who's going to pay these extra costs? 3) You gave the … | |
Re: GUI means Graphical User Interface. It has nothing to do with triggering anything. It's all the pretty stuff in windows, like title bars, sizable windows, arrow cursor, menus, icons -- all the stuff people *think* a computer must have. IMO, if you're such a rookie, you don't need to understand … | |
Re: Also `printf()` is a very expensive way to output a single character. Better to use `putchar('*')` because it's made specifically to output a single character. |
The End.