3,183 Posted Topics

Member Avatar for Peter_36

> 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 …

Member Avatar for AssertNull
0
263
Member Avatar for Traevel

> 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". ;) …

Member Avatar for Reverend Jim
2
444
Member Avatar for V3N0M

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. …

Member Avatar for V3N0M
0
338
Member Avatar for lloydsbackyard

> 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 …

Member Avatar for Dan_15
0
2K
Member Avatar for Jose_12

> 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 …

Member Avatar for deceptikon
0
178
Member Avatar for Jose_12

> 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 …

Member Avatar for Jose_12
0
519
Member Avatar for deceptikon

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. :)

Member Avatar for Yushell
3
1K
Member Avatar for Reverend Jim

> 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.

Member Avatar for happygeek
0
273
Member Avatar for makaijohn9

Please start by posting your code and pointing out where exactly you're having a problem.

Member Avatar for makaijohn9
0
108
Member Avatar for it@61@sec
Member Avatar for Itsdigger
0
158
Member Avatar for panduranga_1

> What is the exact reason that Iphone is more costlier than Andriod phone If we're being honest, the reason is the Apple logo.

Member Avatar for deceptikon
0
184
Member Avatar for directorabbey

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.

Member Avatar for directorabbey
0
274
Member Avatar for mabdullah4

> 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 …

Member Avatar for AssertNull
0
3K
Member Avatar for lanzslumber

> 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 …

Member Avatar for markanderson4
0
4K
Member Avatar for Louie_Rave

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).

Member Avatar for markanderson4
1
4K
Member Avatar for Ghast
Member Avatar for mada Al-Ahmadi

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 …

Member Avatar for mada Al-Ahmadi
0
290
Member Avatar for iPoor

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 …

Member Avatar for iPoor
0
2K
Member Avatar for Shamiah

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); } …

Member Avatar for deceptikon
0
112
Member Avatar for COKEDUDE

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 …

Member Avatar for rproffitt
0
234
Member Avatar for glao

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 …

Member Avatar for glao
0
232
Member Avatar for rproffitt

> 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.

Member Avatar for Raul Perez
0
299
Member Avatar for Centorpe

> 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, …

Member Avatar for Centorpe
0
218
Member Avatar for COKEDUDE

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.

Member Avatar for Soft_1
0
189
Member Avatar for COKEDUDE

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 …

Member Avatar for Soft_1
0
749
Member Avatar for Stuugie

> 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 …

Member Avatar for jkon
0
284
Member Avatar for Fatima Tahir

*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 …

Member Avatar for deceptikon
0
435
Member Avatar for Gà_1

> 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 …

Member Avatar for Beingmahendra
0
217
Member Avatar for lewashby

> 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 …

Member Avatar for lewashby
0
267
Member Avatar for ranjini.jayam

> hello,please tell us the algorithms for extracting text from image consisting of printed text. Because OCR is just as simple as that...NOT!

Member Avatar for wenbuyi
-1
670
Member Avatar for Amr.Mohammad87

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 …

Member Avatar for Ben McNamara
0
203
Member Avatar for COKEDUDE

> 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 …

Member Avatar for Anu_5
0
245
Member Avatar for progteacher2

"More vertically" is too vague. Can you provide a sample of what your teacher is asking for?

Member Avatar for deceptikon
0
113
Member Avatar for SAMMY12345

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.

Member Avatar for jacob81
0
291
Member Avatar for OmniX

> 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)

Member Avatar for Alex_34
0
2K
Member Avatar for ddanbe

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 …

Member Avatar for ddanbe
0
280
Member Avatar for Mayukh_1

> 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 …

Member Avatar for rubberman
0
128
Member Avatar for ravi_14

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.

Member Avatar for deceptikon
0
288
Member Avatar for LibraryCode

> 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 …

Member Avatar for deceptikon
0
347
Member Avatar for COKEDUDE

`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.

Member Avatar for deceptikon
0
438
Member Avatar for COKEDUDE

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); …

Member Avatar for deceptikon
0
247
Member Avatar for COKEDUDE

> 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".

Member Avatar for overwraith
0
157
Member Avatar for COKEDUDE

> 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 …

Member Avatar for deceptikon
0
8K
Member Avatar for negru

> 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 …

Member Avatar for deceptikon
0
183
Member Avatar for zachattack05

> 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 …

Member Avatar for JOSheaIV
0
574
Member Avatar for dileepkumar235

> what is the id and pass. They're hard coded: 11user1 = Pwd1 12user2 = Pwd2 13user3 = Pwd3

Member Avatar for Tanmay_1
0
4K
Member Avatar for overwraith

> 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 …

Member Avatar for deceptikon
0
256
Member Avatar for Dani

'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 …

Member Avatar for happygeek
0
436
Member Avatar for Aeonix

> 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 …

Member Avatar for Aeonix
0
374
Member Avatar for J.C. SolvoTerra

Screenies of old Daniweb isn't half as interesting as the code for old Daniweb. Eew. ;)

Member Avatar for Aeonix
0
363

The End.