3,183 Posted Topics
Re: > `k = n & andmask;` The [bitwise AND](http://en.wikipedia.org/wiki/Bitwise_operation#AND) will set each corresponding bit to 1 if the same bit in both arguments is 1. Otherwise the bit will be set to 0. Since `andmask` only has at most one bit set to 1, the purpose of this statement is … | |
Re: "Number" is ambiguous. Let's throw a wrench into the mix: double a, b; Beware, the answer isn't as simple as you think. :D | |
Re: You've found one problem with `atoi`. Please read [this](https://www.daniweb.com/software-development/c/threads/465515/tribal-knowledge-atoi-is-evil) for more. | |
Re: > the language isn't changing at all. a lot of people are just either too lazy, too uninterested, or, in some cases, too dumb to learn and use it right. Formal rules, good ones at least, are derived from common usage, so the language is indeed changing. Also, common usage … | |
Re: CSV is just a text format, so you'd open and read the file as you would any text file. However, you need to parse the format. For example using a very simple variant of CSV: #include <fstream> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int main() … | |
Re: > `unsigned long hash(char** str )` > `char *str[9]={...` > `key= hash(str[i]);` One of these things is not like the others. If you're not compiling at the maximum warning level, you should turn it up now, because the compiler should point this out for you. I'd also note that your … | |
Re: > I think this is an old micro-optimisation thing that is irrelevant with modern compilers. It was irrelevant even in prehistoric times too, unless you were working with one of the dumbest compilers ever. Even Dennis Ritchie's first C compiler performed this optimization. However, note that the type of `i` … | |
Re: > brother, these aren't my homework problems.these are the questions which are asked in last interview. i couldnt code for these questions. so i posted these questions here. so that someone will comment the code. "*These aren't homework questions, they're just questions I was given to do that I want … | |
Re: Your pointer doesn't point anywhere meaningful. Allocate some memory to it first. Also, there's a [different getline](http://www.cplusplus.com/reference/istream/istream/getline/) for C-style strings that's a member function of `cin`. | |
Re: > Accelerated C++ and C++ Primer 5th edition don't have answers! That's a good thing. Then you won't be tempted to just look at the answer and have to work through the chapter over and over until internalizing all of the information necessary to complete the exercises. You learn *more* … | |
Re: > It's nice only if you also like driving a Model-T automobile made 100 years ago. Orwell is the current and maintained build of Dev-C++. If we were talking about the Bloodshed build I'd agree with you, but for those who like the Dev-C++ IDE, Orwell is a decent modern … | |
Re: > Since you hash define NUM_ITEMS, you don't really need to pass it to functions. What if the caller wants to use something other than NUM_ITEMS without redefining it? Passing the size provides greater flexibility, and just because you *can* do something doesn't mean you *should*. You *can* use NUM_ITEMS … | |
Re: > As soon as i put 7 on im lagging all over the place!!! XP also had significantly smaller hardware requirements for responsiveness. Example, you could get away with 512MB of RAM on an XP box easily, but on a 7 box it won't be usable. | |
Re: > void Change_Address( int *&p, int *&pt) That's C++, not C. | |
Re: > Do you enjoy programming? If yes, why? I like solving problems, creating something useful out of nothing but an idea, and I seem to be good at it. | |
Re: > What do you think? I think you have an overinflated opinion on the power of OOP. C still doesn't have OOP*\[1\]*, and it remains a very popular language. Further, nothing about your requirements suggests that OOP would solve any problems, though it might create some. ;) > cannot get … | |
Re: It's probably a timing issue. I've encountered similar issues when things happen too fast between closing the file and trying to delete it. A workaround would be to retry the deletion a few times after a short pause: public static bool SafeDelete(string path, int tries = 1, int wait = … | |
Re: I'd start by putting the database update logic into a few key events for the DGV, such as `Validating`. But keep in mind that with a real-time update, you need to be *very* robust in handling DGV errors. | |
Re: > It is not common to use a messagbox in a console application, that's why the reference to Forms is not included by default. A library project doesn't reference `System.Windows.Forms` by default either, but it's very common to define form components in a DLL. I'm not convinced the default references … | |
Re: Well, you know how many days are in each month, and what weekday the year starts, so the algorithm stands out immediately as a couple of nested loops with a few counters that wrap around at appropriate times. You're looking at around 10 lines of code. Don't over complicate things, … | |
Re: Does this have anything to do with James' new house? Are we hosted in a grungy suburbia basement!? ;p | |
Re: Rather than bind the combo box values directly to your table, built a list in memory with the contents of the table and any other extra values you want. Then bind to the list. Alternatively, you can adjust your select statement for `ddtable` to include selection of the default value … | |
Re: Try using `System.DbNull.Value` instead of `vbNull`. `vbNull` doesn't represent what you think it represents. ;) | |
Re: > I always thought I had been programming in C++ :/ You have (probably). But it gets interesting when extensions and libraries are thrown into the mix. Here are the high level options: * Standard C++: Only uses libraries and features clearly defined by the ISO standard document. It's highly … | |
Re: Example please. While I can guess what you mean, you're not using conventional terms. | |
Re: Not enough information. Sockets have an easy and obvious way to set the port number, so I can only assume you're asking for something more involved. | |
Re: While I haven't personally hit that case (I'm neurotic about my own check-ins and thoroughly review anything I take from elsewhere), I *have* seen it with libraries. We had a utility library that contained a bug in XML serialization that was intermittent and not caught for over a year. By … | |
Re: You could just ask the questions and see what answers you get. ;) | |
Re: `p` is a pointer to an array, not a pointer to an element of the array. You'll need to dereference the pointer, then treat the result like an array: printf("%d\n", (*p)[1]); | |
Re: > That is a fantastic solution Eh, I'm not a fan of it. It's tied heavily to `fgets`, requires a special buffer that can easily cause name conflicts, lacks flexibility in where it can be called, and ignores error handling. It's inefficient in general, and most importantly, neglects that the … | |
If you have any ideas for a code snippet you'd like to see, please post them here. We can't depend on the snippet writers to come up with all of the ideas, can we? ;) | |
Re: > I hadn't built any fault tolerance in. Not a good habit to get into. "What if this fails?" or "what if the user doesn't enter what I expect?" are key questions that should be answered very early in development. Otherwise you'll end up with brittle code. Further, adding error … | |
Re: > For example, if key 0 contains a vector containing a b c d and key 1 contains a vector containing 1 2 3 4, would there be any way to output a 1 b 2 c 3 d 4, instead of a b c d 1 2 3 4? … | |
Re: I want some questions that aren't hopelessly vague. But apparently getting what you want is a rare occurrence. Can you be more specific? | |
Re: Please define your terms. I've seen a number of different, conflicting, and overlapping definitions of "programmer" and "software engineer". It's difficult to answer your question without first understanding what those terms mean to you. | |
Re: > I've never used C++/CLI, but it looks like std::string is a distinct type from System::String and presumably Console::WriteLine only works with the latter as it is a .net method and std::string is a C++ class. Correct. `System::String^` is a managed reference type which is not directly compatible with `std::string`. … | |
Re: In socratic fashion, I'd ask where does `x` point at the start of the second loop? | |
![]() | Re: Depends on what tutorial you've been following. You can code against an existing database (in which it's your job to create it) or you can code against a new database where your context will attempt to create the database when needed. In both cases, of course, you need something to … ![]() |
Re: Yes. Depending on the version of VS, you may have a setup project available either built in or from a plugin. Otherwise, something like InstallShield LE, InnoSetup, or WiX can offer freely available installers to package your solution. I'm not a huge fan of InstallShield LE, but for simple installers … | |
Re: Forget that you're dealing with `miter->second` for a moment. How would you display the contents of a vector? We know `cout` doesn't have an overloaded `<<` operator for collections, so you're stuck with some variant of a loop. This comes immediately to mind: for (auto it = v.begin(); it != … | |
Re: The file is embedded in your assembly, it has no path. If you want a file you can work with outside of the resource interface, then consider `GetManifestResourceStream` from the assembly object for a little more control. | |
Re: > `m==textBox1->Text;` Two things: 1. `m` is declared as `std::string`, while the `Text` property is declared as `System::String^`. The two types are not directly interchangeable. 2. `==` does a comparison, not an assignment. Also note that `m` only exists inside the event handler, so if you need it beyond that, … | |
| |
Re: `arrayofstr = malloc(9 * sizeof (char*))` is misplaced. Move it outside of your first loop. | |
Re: [Clickie](https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types) to learn about the difference between a pointer to a function and a pointer to a member function. They're not even close to the same thing. | |
Re: Most image processing libraries let you do the work using memory streams. I'd start by looking through NuGet for popular libraries to help. | |
Re: > But I am declaring it in the class right? Yes, but a declaration is not necessarily a definition. In the case of non-const static data members, the declaration is unconditionally *not* a definition. Hence why you need to provide a definition outside of the class. > Here, they are … | |
Re: It's not really that advanced, but conceptually, structures are stored and accessed as a punned array with padding between the "objects" to facilitate faster individual access by the CPU (which some compilers can optionally change or remove to alter or make consistent the storage size). The template, which I interpret … |
The End.