3,183 Posted Topics
Re: On a side note, the technique you're showing is called [type punning](http://en.wikipedia.org/wiki/Type_punning). It's rather common in lower level code. If you're feeling frisky, an example of union-based punning to break down a floating-point value can be found in one of my teaching libraries [here](https://code.google.com/p/c-standard-library/source/browse/includes/std/math.h#39) and [here](https://code.google.com/p/c-standard-library/source/browse/src/std/math.c#94). > In the same … | |
Re: `...` at the end of a function's parameter list says that the function takes a variable number of arguments. I'll leave it at that so you can try to figure out why it works, then I can tell you *how* it works. :) One thing to note though is that … | |
Re: It really depends on what kind of code you'll be working with. If you're only doing system level stuff, learning UI components isn't as important. If you're only doing the front end of applications, learning the niggling low level features isn't as important. Repeat ad infinitum for whatever feature you … | |
Re: In terms of e-peen points, you're doing okay. What really matters is the intangible reputation you earn that is what people who matter think of you. And that kind of reputation takes time. Were I concerned about reputation, I'd wonder what people thought about a public annoucement of leaving after … | |
Re: > I also think it maybe best if DaniQueen introduce a way to decrease points to those who are doing this I'm not entirely sure what you mean by "points", but voting and reputation work both ways. If you find someone spoonfeeding beginners, then by all means given them a … | |
Re: > In the first one, why would we start writing to the file at position n \* recsize instead of position 0? Judging from the code, the intention is to overwrite an existing record that may or may not be the first record. If you always used position 0, you'd … | |
Re: The compiler is correct, `varying` doesn't exist at that point. You declare it in `textBox1_TextChanged`, but try to use it in a completely different method. Why not just use `textBox1.Text` directly and not worry about handling `TextChanged`? MessageBox.Show("Hello!", textBox1.Text, MessageBoxButtons.OK); | |
Re: It's impossible to answer your question as asked because the benefits of cores versus clock speed are situational. What's the average use case of the intended machine? | |
Re: Would you be kind enough to explain what exactly the problem is? It's too early for guessing games here. ;) | |
Re: Richard, are you using Google Translate, or something? | |
Re: This is actually a common exercise, with well known solutions. But the neatest trick is to make two passes over the string: 1. First Pass: Reverse all characters in the string (ie. "treboR si eman yM") 2. Second Pass: Reverse each *word* in the string Nothing fancy, just super basic … | |
Re: > Or do you just not ask that question and automatically stay away from any undefined operations? No and yes, respectively. Undefined behavior is super bad, but questioning *why* something is undefined improves understanding of the concept and helps one to avoid it in cases that aren't textbook examples. | |
Re: The method belongs to the class and not any single instance of the class. | |
Re: For smaller projects I place enums in a project-level Enumerations.cs file. For larger projects I tend to break things down into folders where each folder holds related stuff and might have its own Enumerations.cs file. For tiny projects or strongly self-contained classes where only the class needs access to it, … | |
Re: Note that Daniweb prohibits discussion of hacking. I'll allow this thread because the question is very specific and more about C in general, but take care in asking for details about how the exploit works. | |
Re: Since this is a final project, I tend to agree with your teachers. You should have all of the building blocks available at this point to complete the project, they just need to be put together. Perhaps if you asked a more specific question rather than just posting your assignment, … | |
Re: > What's your preferred method for saving your program's settings? It depends on the settings and the complexity of the program in my case. For simpler things, I prefer app.config. For more complex things I prefer my own XML file using serialization. Sometimes I'll go with storing settings in a … | |
Re: What compiler are you using? | |
Re: > how to overload bitwise i.e << and >> operators ? The same way you overload any other binary operator. There's no magic to the shift operators, though if you're not careful then precedence rules might bite you in the ass when you use them. | |
Re: > what tips have you learned over time? The technical stuff is easy. My biggest wins in UI design have come from end user feedback. Things I find to be obvious are often obtuse to an end user, and knowing what confuses them has helped me to build intuitive interfaces. … | |
Re: > You can't do that. There is no way other people can use your "project" without also having purchased and installed MS Access. I'll be sure to let my clients know that the software they're using is impossible. ;) | |
Re: Sorry to hear that. Perhaps if you offered something significantly less vague, someone might be able to help troubleshoot. | |
Re: > I need to be able to take a string and put it into an array of chars, how can i do this? If the string is a literal, it's as easy as this: char test[] = "08/11/2014"; If the string is obtained some other way, and all you have … | |
Re: Imagine an array: {1, 2, 3, 4, 5, 6} Now imagine dividing it up into pairs: {1, 2} {3, 4} {5, 6} Then swap each pair: {2, 1} {4, 3} {6, 5} Put back together you have the final result: {2, 1, 4, 3, 6, 5} Which in pseudocode would … | |
Re: > Need it in 15 mins Yeah...15 minutes would be *really* pushing it even for an expert who knows exactly what to write and doesn't require any debugging. I'm happy to offer advice to help you learn when you have more time, but for this particular project, you're SOL. | |
Re: I have a beard, and a damn fine looking one at that. But off the top of my head, I can't think of anyone else I've worked with recently in the IT sphere that had any significant facial hair. | |
Re: It somewhat depends on how much you do exactly with those tools and if you run them all at once. For example, Photoshop alone can be a massive resource hog. One of my buddies is a photographer, and for several years he used Mac exclusively because of the higher RAM … | |
Re: Start from the simplest and work your way up: RLE, sliding window, LZW, and Huffman are the simpler algorithms. They're relatively easy to implement and reason about. Production level algorithms tend to be either proprietary or variations/combinations of the simpler ones. Also keep in mind that different types of data … | |
Re: > Why will I need to update each and every source file? For fun, let's use `printf` as our example even though it's unlikely to change for the forseeable life of C. int printf(const char *fmt, ...); int main(void) { printf("Hello, world!\n"); return 0; } You do that in every … | |
Re: in·her·i·tance (n) 1. money, property, etc., that is received from someone when that person dies 2. something from the past that is still important or valuable 3. the act of inheriting something | |
Re: > Why does it need int in postfix and not in prefix? This is a case of Bjarne Stroustup being *too* clever. The two member functions need a different signature to resolve ambiguity between them. C++ doesn't differentiate between return types when comparing signatures, so it has to be done … | |
Re: > The answer to that question is: "It's usually advertised with the hdd itself. Advertised poorly. Manufacturers tend to advertise in increments of 1000 rather than 1024, so a 1GB drive is smaller than a binary minded person would expect. Throw in necessary formatting and system reserved space, and the … | |
Re: I think a better question is why did you reach the point where `malloc` is failing? With virtual memory being standard operating procedure in modern OSes, it should be extremely rare unless you're doing something silly. Can you elaborate on what problems you're doing and how you're solving them? | |
Re: > Playing with the structure examples in the book reminds me of accessing attributes to a python Class That's not a bad analogy. A structure in C++ is just a class with different default access (public instead of private). A union is different in that all members of a union … | |
Re: Wires with the same base color are paired, so it makes sense to distinguish them somehow as pairs. They can't both be a solid color or you'd confuse them on each end of the cable. Thus, the white stripe. | |
Re: > May be any platform, any compiler, I just want to do the complete procedure myself. The complete procedure really does vary between compilers and operating systems and the documentation for your compiler will give you specific instructions. For a static library it's super easy. Just create a standalone project … | |
![]() | Re: Since you're already using C++/CLI, why not initialize a `DateTime` object with the `String^` and then use the `ToLocalTime` method? What exactly does the string contain? Is it a standard UTC format? ![]() |
Re: Double check that your credentials are correct. I've seen this happen when the password expires or is changed. | |
Re: Yup, variables in a nested scope hide variables with the same name in parent scopes. | |
![]() | Re: For this I'd select the count of matching records: select count(*) from tblSchoolYear where schoolYear = @schoolYear If it's greater than 1, you have duplicates and can show a message box. However, that particular query strikes me as producing false positives unless the schoolYear column is largely unique. You'd likely … ![]() |
Re: Command line arguments are always strings. What those strings represent depends on your code and how you use them. But yes, if an argument represents an integer and you want to store it in an integer type, you need to convert the string with something like `strtol` (`atoi` is not … | |
Re: What arguments are you planning on supporting? Are they the strings to convert or switches that alter how the conversion happens? The first step is to solidify your understanding of how the program should work at a higher level, then you can dig down and implement the pieces. | |
Re: > Am I using the +1 wrong? There's not really a way to use it wrong, barring full out abuse like automatically downvoting every post from a member regardless of post content. Typically I use the voting system as a type of kudos. If I think a post is well … | |
Re: > Assuming the size of the register is 8 bits and the leftmost bit is reserved for sign shouldn't the size be -127 to +127. It is. Well, that's the required minimum size defined in the C standard. However, the range can be extended by any implementation. Particularly, the extra … | |
Re: > But try again after including the library function #include<conio.h> as well. Not only will this not solve the problem, it also destroys code portability by requiring the compiler to support a non-standard library. | |
Re: This is an extension method I use for that purpose: /// <summary> /// Separates a list of items into sub-lists of chunkSize chunks. /// </summary> /// <param name="items">The original list of items.</param> /// <param name="chunkSize">The desired size of each sub-list.</param> /// <returns>A list of sub-lists of up to size chunkSize.</returns> … | |
Re: > Now before you all go with strstr I'm not sure I'd recommend `strstr` for this anyway. ;) > i dont want to use <string> You mean `<string.h>`? That's where `strstr` is declared. `<string>` defines the `std::string` class. > Any suggestion for solution of this issue is a big Thank … | |
Re: I'm not entirely sure I understand the problem. A `bool` property will display appropriately as a checkbox by default in a `DataGridView`. So you'd add such a property: bool Availability { get; set; } Then convert the result of the combobox as necessary (varies depending on how you've got the … | |
Re: > In the program below what is the difference between rand and srand? `rand` generates a pseudorandom number. `srand` seeds the generator that `rand` uses. The seed essentially determines what the first random number will be and affects subsequent numbers in the sequence. If you don't call `srand`, the seed … |
The End.