3,183 Posted Topics
Re: > What I DON'T understand is why srand(time(NULL)) and rand, which is what we're all taught to use, are such lousy random number generators Probably for the same reason `gets` and `atoi` are so lousy. The interface was simple, they were "good enough" at the time, and time/experience changes what's … | |
Re: > Just keep pressing the little X a bunch of times in a row until they are all cleared out. Yeah, clicking the X 300 times with a couple second wait between each popup is a good way to say "you need to log out and never come back". ;) … | |
Re: I agree with AssertNull, it's very likely the newline character mucking things up. Your compiler (or compiler settings) probably aren't zeroing out local variables while AssertNull's is, which explains the code working in one place but not another. You can verify this by initializing `_artichoke`, `_beet`, and `_carrot` to 0. … | |
Re: > so maybe you need to write cpp.sh is an online compiler that you can test your theory with. It takes a few seconds to confirm that this does not work. conio is a non-standard library, which means not all compilers (most in fact) do not support it. Those that … | |
Re: > As I recall you should use fseek and ftell to get the file size[...] That's fine for simple use cases, but it gets troublesome very quickly. For example, large files introduce a hard limit for both getting the size and using it due to `fseek` and friends working on … | |
Re: > to determine if it is a number, keyword or an identifier This is a key statement to me, because it sounds like you're writing a lexer. If that's the case, it's not really as simple as throwing characters into an array (or some variation of \*scanf); you need to … | |
I'm sure I've mentioned this type of wrapper class for accessing databases in a provider-agnostic manner before, but never posted a functional implementation. So here it is. Questions, comments, and suggestions are welcome as always. :) | |
Re: > I had much more respect for his "comedy" news than I have for "real" news". When The Onion reports things and you can't tell the difference between them and "real" news, there's clearly a problem. Journalism these days is more about pushing agendas than informing people. | |
Re: Please start by posting your code and pointing out where exactly you're having a problem. | |
Re: The option to downgrade will go away on its own after one month, IIRC. | |
Re: > What is the exact reason that Iphone is more costlier than Andriod phone If we're being honest, the reason is the Apple logo. | |
Re: As rubberman mentioned, those typedefs are specified in `<stdint.h>` (for C) and `<cstdint>` (for C++). But note that `<cstdint>` wasn't officially supported by C++ until the C++11 standard, so if you're not compiling against that standard then defining your own or using the Boost library would be options to consider. | |
Re: > But this does not work.If user input invalid value it start looping. Indeed. When `cin` fails to make a conversion, it doesn't remove the invalid characters from the stream. So you have two options: 1. "Flush" the stream (not recommended). 2. Read a full line of data and then … | |
Re: > Why my images look messy? Because we use CSS to align the images, it's not like a Word document. You'll need to organize the post so that it doesn't look goofy, much like you would in a web page. Note that we include a live preview underneath your post … | |
Re: Yes, we can help you. Please ask specific questions beyond "can you help me?" (the answer is yes) and "what statements can I use?" (the answer is any of them). | |
Re: https://msdn.microsoft.com/en-us/library/122bwwcc.aspx | |
Re: In general if you're receiving an error, it's best practice to post the error. However, at a glance I see two potential issues, taking into account that Turbo C++ is an ancient and non-standard compiler: 1. Case matters. On line 9 you use `Int` instead of `int`. 2. `div` is … | |
Re: You've encountered one of the most irritating things about .NET (at least for me): image processing is quite wanting. I don't work with TGA much, but I work extensively with TIFF. The .NET imaging libraries either do not support TIFF readily, such as PictureBox, or the support for conversion of … | |
Re: Allow me to reformat your code in the way the compiler sees it. The problem should be easier to locate that way: #include <stdio.h> main(){ int order; int price=5; int bill; int billd; int billf; scanf("Amount of Order: %d",& order); if (0<=order<=10) ; bill=(order*price); billd=(bill*0.1); billf=(bill-billd); { printf("Bill: %d",billf); } … | |
Re: Code::Blocks uses MinGW by default, which is a port of GCC. That said, `itoa` should be available, if I recall correctly. Normally I'd ask what your switches are and to post some code which fails to find `itoa`, but a standard alternative is `snprintf` (or `sprintf` if you're not running … | |
Re: I suspect the confusion is the name `p`. You have two variables with the name `p`, which in this case is perfectly acceptable. However, it might be that you're seeing them as the same object, which is false. Consider this modification to `fun`: void fun(int *meep){ *meep = 15; meep … | |
Re: > How about you? Got any good replies like that? The worst is when people assume that because the code compiles (ie. no fatal errors) then it's correct. Oddly enough, warnings often tell the real story about issues at runtime. | |
Re: > This code was coverted from VB by simply replacing the 'And's and 'Or's. One thing to note is that these are not comparable operators. `And` and `Or` are not short circuiting in VB, yet `&&` and `||` are in Java. Whether this is relevant depends heavily on your logic, … | |
Re: The comment tells you: "declared as an integer constant of type **unsigned long** int". The UL suffix explicitly tells the compiler that you want a value of type unsigned long. | |
Re: First and foremost, you don't need to cast the return value of `malloc`. In fact, doing so can hide legitimate errors such as failing to include `<stdlib.h>`. Second, `sizeof(char)` is guaranteed to be 1 in all cases, so things like `sizeof(char) * some_int` are unnecessarily complex. > I have seen … | |
Re: > Well, I was feeling under-qualified based on what I was seeing out there for available positions. Job "requirements" lie like a rug more often than not, and the actual requirements tend to be significantly lower. But by demanding the world, it's easier to catch the better talent from the … | |
Re: *Technically* the best case is the input tree is already AVL balanced, so the solution is legit from a complexity standpoint. The more practical problem with this solution is it adds a verification step regardless of the input tree and slows down the algorithm even when you need to adjust … | |
Re: > This, `malloc(sizeof *new);` should be `malloc(sizeof(Node))`. It can be, but doesn't need to be. That call to `malloc` is correct as it stands, and actually best practice. `new` is a pointer to `Node`. The operand to `sizeof` is the dereferenced `new`, which ends up being evaluated as `Node` rather … | |
Re: > What am I missing here? Two things: 1. `Student s(pName)` is creating a variable called `s` via the `const char*` constructor of the `Student` class. I get the impression you're confusing this with a function declaration given your mention of a "variable name". 2. You can generally add a … | |
Re: > hello,please tell us the algorithms for extracting text from image consisting of printed text. Because OCR is just as simple as that...NOT! | |
Re: Congratulations! You've found an inconsistency in terms with binary trees. :) There are actually a few of them, but counting levels is a notable one. As James said, each paper or book should be internally consistent, but you'll want to take care to follow the source material carefully. If you … | |
Re: > how would you do the math with the expression? Push any operands. On an operator, pop the number of operands required, then push the result. Repeat until there's only a result. For example, `1 + (2 * 4 + 3)` would be converted to `1 2 4 * 3 … | |
Re: "More vertically" is too vague. Can you provide a sample of what your teacher is asking for? | |
Re: From my experience thus far, Windows 10 is fine on a desktop, but frustrating on a tablet. In particular, the Edge browser is too incomplete to be usable at this point, and I use my tablet largely for browsing the web. | |
Re: > So for this which header file we have to include. [RTFM](http://msdn.microsoft.com/en-us/library/windows/desktop/aa376868(v=vs.85).aspx) | |
Re: Not a strange question at all, and we got it quite often when the TOS explicitly claimed copyright to any posts made (it doesn't appear to do so any longer). In the past, ownership of post content was in practice only to absolve us of responsibility for storing, editing, and … | |
Re: > Will the malloc for ptr2 or ptr3 will allocate the same memory that has been freed by free(ptr1).. Maybe, maybe not. It really depends on the memory manager `malloc` uses for that specific implementation. I wouldn't make that assumption though. > what will happen internally if I free a … | |
Re: You have a circular reference in your includes. The easiest fix as-is would be to remove the include for LinkedList.hpp in your LinkedNode.hpp header. | |
Re: > how would i need to change this code to accept strings insted integers in avl tree? Agreed with David W. Though the function seems entirely unnecessary. It's generally better practice to avoid having functions that do multiple things (ie. gather input *and* insert into a data structure) in favor … | |
Re: `program` accepts `big_boy_counter` and `lower_bound_of_big_boy_counter` as `int*`. You then pass the *address* of those to `declaration_list`, which makes them both `int**`. But `declaration_list` also expects `int*`, which means you're passing a value of incompatible type. | |
Re: The array to pointer conversion you're probably familiar with only applies to the *first* dimension of an array. The only solution here is to dynamically allocate the strings as well such that you originally have a `char**`: char **strings_like_tokens = malloc(503 * sizeof *strings_like_tokens); ... split_string(line, strlen(line) + 1, strings_like_tokens); … | |
Re: > This is C right? With any luck it's C++ as best practice in C is to specify `void` as the parameter list. But yes, there's no termination condition in `declaration_list` to stop the recursion, so it'll go until the machine says "uncle". | |
Re: > I'm not sure of the rationale behind not allowing VLA (variable length array) initializers It's a combination of not complicating the compiler and not hiding an extremely volatile runtime task behind benign syntax. Even in C99+, VLAs are risky and not something I'd recommend using. Robust code shouldn't use … | |
Re: > What books would you recommend for data structures and algorithms in C language? I often recommend Algorithms in C by Robert Sedgewick. The concepts are well written and researched, and this is the biggest benefit of the book. A subtle benefit is that the code is both horribly formatted … | |
Re: > Any reason why you would do it one way over the other? Three words: don't repeat yourself. Saying `if (x == true)` is redundant. The context alone tells you that `x` represents a boolean. If you're being redundant "just in case", then would that be an argument for stuff … | |
Re: > what is the id and pass. They're hard coded: 11user1 = Pwd1 12user2 = Pwd2 13user3 = Pwd3 | |
Re: > The problems I guess would be navigating from a language with a certain feature to a language without a certain feature That's one problem, yes. Another would be choosing a consistently compatible translation route when the target language has multiple ways of doing the "same" thing that in practice … | |
Re: 'Lil bit, yeah. It's not a deal breaker, just something that takes getting used to. * I think the signature is out of order. You see the post content first, then who posted it. Would I be correct in guessing that you wanted us to view posts on their merits … | |
Re: > or cracker are going to crack it easier, steal people's data and people will start disregarding software as unsafe. Here's my take on it: insecure software will be insecure regardless of code availability. Open source certainly makes insecure software easier to crack, but the underlying problem isn't being open … | |
Re: Screenies of old Daniweb isn't half as interesting as the code for old Daniweb. Eew. ;) |
The End.