3,183 Posted Topics

Member Avatar for surfingturtle

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

Member Avatar for surfingturtle
0
201
Member Avatar for Bhavesh Nariya

"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

Member Avatar for Oddytech
-3
2K
Member Avatar for COKEDUDE

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.

Member Avatar for deceptikon
0
139
Member Avatar for Reverend Jim

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

Member Avatar for Reverend Jim
7
5K
Member Avatar for Farhan_4

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

Member Avatar for mellertson
0
19K
Member Avatar for can-mohan

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

Member Avatar for can-mohan
0
394
Member Avatar for Mahnoor_1

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

Member Avatar for Mahnoor_1
0
282
Member Avatar for sureshshan1292

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

Member Avatar for ekambaram
2
3K
Member Avatar for John A

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

Member Avatar for Khawaja Ghulam
11
7K
Member Avatar for Dave Sinkula

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

Member Avatar for shahidali6
11
10K
Member Avatar for ~s.o.s~

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

Member Avatar for mack1
29
5K
Member Avatar for vegaseat

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

Member Avatar for David_50
5
746
Member Avatar for Ancient Dragon
Member Avatar for happygeek

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

Member Avatar for XP78USER
6
10K
Member Avatar for vijaykrishnabor
Member Avatar for theredhosting

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

Member Avatar for bordogamesdev
1
420
Member Avatar for Curious Gorge

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

Member Avatar for Frederick2
0
468
Member Avatar for iamahar

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

Member Avatar for ddanbe
0
164
Member Avatar for mad_1

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.

Member Avatar for deceptikon
0
232
Member Avatar for Saboor880

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

Member Avatar for DaveAmour
0
2K
Member Avatar for munchlaxxx

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

Member Avatar for 0igo
0
17K
Member Avatar for Dani

Does this have anything to do with James' new house? Are we hosted in a grungy suburbia basement!? ;p

Member Avatar for blud
0
302
Member Avatar for ramkishor

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 …

Member Avatar for ramkishor
0
213
Member Avatar for PM312

Try using `System.DbNull.Value` instead of `vbNull`. `vbNull` doesn't represent what you think it represents. ;)

Member Avatar for PM312
0
2K
Member Avatar for Asira18

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

Member Avatar for David W
0
372
Member Avatar for Zahid_5

Example please. While I can guess what you mean, you're not using conventional terms.

Member Avatar for deceptikon
0
99
Member Avatar for ashutosh9305

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.

Member Avatar for deceptikon
0
35
Member Avatar for pritaeas

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 …

Member Avatar for deceptikon
0
144
Member Avatar for DaveAmour

You could just ask the questions and see what answers you get. ;)

Member Avatar for DaveAmour
0
141
Member Avatar for Clearner123

`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]);

Member Avatar for Clearner123
0
173
Member Avatar for jephthah

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

Member Avatar for David_50
0
6K
Member Avatar for deceptikon

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

Member Avatar for vegaseat
3
749
Member Avatar for killingmonk

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

Member Avatar for Leslie_1
0
245
Member Avatar for collin_ola

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

Member Avatar for deceptikon
0
304
Member Avatar for mobizeyai

I want some questions that aren't hopelessly vague. But apparently getting what you want is a rare occurrence. Can you be more specific?

Member Avatar for ddanbe
0
95
Member Avatar for Gift_3

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.

Member Avatar for mike_2000_17
0
294
Member Avatar for Aeonix

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

Member Avatar for Aeonix
0
23K
Member Avatar for raghavanp
Member Avatar for マーズ maazu
0
245
Member Avatar for lithium112

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 …

Member Avatar for lithium112
0
231
Member Avatar for basit_3

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 …

Member Avatar for deceptikon
0
173
Member Avatar for collin_ola

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

Member Avatar for collin_ola
0
563
Member Avatar for feyisa
Member Avatar for Navee30

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.

Member Avatar for JerrimePatient
0
9K
Member Avatar for basit_3

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

Member Avatar for ddanbe
0
237
Member Avatar for S-e-c-r-e-t
Member Avatar for basit_3
0
426
Member Avatar for can-mohan

`arrayofstr = malloc(9 * sizeof (char*))` is misplaced. Move it outside of your first loop.

Member Avatar for deceptikon
0
210
Member Avatar for prahesh

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

Member Avatar for deceptikon
0
192
Member Avatar for batoolhussain

Most image processing libraries let you do the work using memory streams. I'd start by looking through NuGet for popular libraries to help.

Member Avatar for deceptikon
0
73
Member Avatar for nitin1

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

Member Avatar for deceptikon
0
335
Member Avatar for Tcll

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 …

Member Avatar for Tcll
0
159

The End.