3,183 Posted Topics

Member Avatar for daniel1977
Member Avatar for lewashby

Comparing floating point values for equality is also fraught with peril. You'd be better off converting them to strings and then doing the comparison. That way the not insignificant work of handling a precise representation of the value is deferred to the standard library. A "close enough" test is often …

Member Avatar for deceptikon
0
108
Member Avatar for xHellghostx

> That means the size of the array is unknown. That means you shouldn't be using an array. Use a List<> instead, unless this is a homework assignment where the whole point is to learn how to work with arrays. Though such an assignment seems silly since the Array class …

Member Avatar for Ketsuekiame
0
629
Member Avatar for on93

Didn't you write it? Why would you need someone to explain to you how your own code works?

Member Avatar for Lucaci Andrew
0
107
Member Avatar for zvjezdan.veselinovic

> and change line 138 to use getchar(). That won't work because getchar() requires a newline to terminate input in the shell. getch() is used because it's a non-blocking input function. This is an appropriate usage of the conio library. > perhaps a while loop around lines 138-168 Yes. Basically …

Member Avatar for deceptikon
0
487
Member Avatar for triumphost

> How can I calculate CLOCKS_PER_SEC.. It is defined as 1000 in ctime. I don't want it defined. I want to calculate the actual value.. `CLOCKS_PER_SEC` is a standard macro, you can ignore it if you'd like, but you shouldn't redefine it. > So what is CLOCKS_PER_SEC and why is …

Member Avatar for deceptikon
0
2K
Member Avatar for lewashby

> Now that I've converted the formula over to C++ it's not working out. It's the wrong formula. This is correct: bool is_leap_year(int year) { return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); } > if ( year % 4 …

Member Avatar for lewashby
0
197
Member Avatar for Hopp3r

> What is the simplest way to do this? It's not a matter of simple or not, it's a matter of *possible* or not. If you're not given a size, can't assume a size, and there's no sentinel value marking the end of the array then you're shit out of …

Member Avatar for NathanOliver
0
2K
Member Avatar for prakhs

> Can any 1 please help me with it? What kind of help do you want? You clearly haven't done anything yourself, so it's hard to construe "help" to mean anything except "tell me the solution and how to code it".

Member Avatar for Adak
0
186
Member Avatar for on93

In lines 75-79, you unconditionally delete the head if it's the only node in the list. What if `id != head->st.id` in that case? As for successfully deleting the first node when it matches the id, consider adding another clause between lines 79 and 80 that handles a true deletion …

Member Avatar for on93
0
332
Member Avatar for Doogledude123

> operand types are incompatible ("char" and "const char *") You should use the standard C++ string class. C-style strings are awkward, low level, and easy to get wrong (as evidenced by this thread). However, let's look at the problems in your original code, and ignore all of the wrong …

Member Avatar for Doogledude123
0
283
Member Avatar for myk45

> Now, there is no way to esure safety, and this is a potential unsafe operation.(if the pointer tries to access data from Derived) It's completely safe...because it won't compile. ;) > I feel i am missing something here. Why is there no way in C++ to ensure the safety …

Member Avatar for myk45
0
611
Member Avatar for garyjohnson

> What is the benifit to classes? They help with the organization of large projects.

Member Avatar for diafol
0
147
Member Avatar for mayankjain05

> also will the answer be same even i declare the array dynamically?? The results will typically be *worse* when accessing dynamically allocated memory out of bounds.

Member Avatar for mayankjain05
0
108
Member Avatar for n@nnouss@

Please ask a specific question. Guessing what kind of "help" you want will result in a lot of wasted time and frustration.

Member Avatar for n@nnouss@
0
650
Member Avatar for pivren
Member Avatar for Asmaa_2

> @AD: toupper() and tolower() seem to return int and not char. That's only to support an argument of EOF (in which case EOF is the return value). If you never expect to pass EOF, such as when it's a stopping condition prior to calling toupper() or tolower(), there's no …

Member Avatar for MandrewP
0
500
Member Avatar for Elixir42

> delete CurrentNode; > CurrentNode = CurrentNode->pNext; This is the problem. You aren't guaranteed to have a valid pointer even immediately after deleting it. It could be reused just that fast, or more likely, invalidated for debugging purposes. The correct way to traverse and delete a linked list is with …

Member Avatar for Elixir42
0
237
Member Avatar for aswekown

> My problem is after change the value of Masked raider the jimmy changed,but when set jimmy = "not ok"; > Masked raider did not change,how to explain it? When you changed `jimmy` to "not ok", you pointed it to a *different* object (the string literal "not ok"). At that …

Member Avatar for deceptikon
0
127
Member Avatar for jeeva.kumar.33

> So any title regarding this field guys??? Why don't you figure out what the project will be, then devise an appropriate title? It baffles me how people can take *years* of college and still be unable to think of something as simple as a title. Did you learn nothing …

Member Avatar for deceptikon
-3
159
Member Avatar for MU.vo.doi.vai.coi.MU

You could build the array up manually using nested explodes: $fields = explode(',', 'Name: John, Age: 20, Phone number: 12343223'); $result = array(); foreach ($fields as $field) { $kvpair = explode(':', $field); if (isset($kvpair[0]) && isset($kvpair[1])) { // Both key and value exist (expected case) $result[trim($kvpair[0])] = trim($kvpair[1]); } else …

Member Avatar for MU.vo.doi.vai.coi.MU
0
131
Member Avatar for fsdhf_20

What have you done so far? We require proof of effort before offering any help.

Member Avatar for CrazyDieter
0
166
Member Avatar for dr_iton

Well, an obvious first attempt is to loop through the items in the listbox and not update your textbox if the random number already exists: xhiro = "1301" + numri; bool exists = false; foreach (var item in listbox.Items) { if (item == xhiro) { exists = true; break; } …

Member Avatar for tinstaafl
0
159
Member Avatar for king03

I think it's a good choice in general, but I know nothing about you, so I can't say if it's a good choice for *you*.

Member Avatar for king03
0
276
Member Avatar for samii1017

I think in posting only a "portion" of the code, you've edited it into nonsensicalness. Could you post more code, or ideally, a small but complete program that exhibits the problem.

Member Avatar for Moschops
0
159
Member Avatar for herge

Warning 4996 is the height of stupidity, so I'll hard disable it in the project settings without any hesitation. Go to your project properties, then uder C/C++->Advanced there will be an option for disabling specific warnings. Add 4996 to that list and enjoy never seeing that ridiculous warning again.

Member Avatar for deceptikon
0
238
Member Avatar for deceptikon

For those of you familiar with the latest C++ standard, what do you think of [uniform initialization](http://en.wikipedia.org/wiki/C%2B%2B11#Uniform_initialization)? Listening to folks like Herb Sutter, it seems like the intended purpose is to be completely pervasive, which obviously changes the look and feel of C++. Do you plan on using it everywhere …

Member Avatar for vijayan121
0
428
Member Avatar for hwoarang69

> 'Systems' and 'Programmer' sound like 2 separate jobs to me. They're not. The difference is that a systems programmer will generally write code that sits below userland and provides services to the hardware or OS. This is as opposed to an application programmer that writes programs for users. I've …

Member Avatar for CGSMCMLXXV
0
148
Member Avatar for Archit Gupta

> `gets(rm[i].type);` > `fflush(stdin);` These lines are in the wrong order. I'll let someone else chastize you over using fflush() on an input stream, because it's obvious that you're using Turbo C++. I'll also let gets() slide, but keep in mind that it's the worst possible choice for string input. …

Member Avatar for Archit Gupta
0
285
Member Avatar for glenndr_15

You can do a simple replace on the string: textBox.Text = textBox.Text.Replace("Yes", "NO") Changing the color is a different matter. I assume you want to change only the replaced text to red, which won't work unless you're using a rich text box. If it's just a regular text box then …

Member Avatar for deceptikon
0
120
Member Avatar for deceptikon

No bells and whistles, just a quickie millisecond timer showing an alternative to the far less portable clock_t method. A test main() is included, just define TEST_DRIVER as a macro or remove the conditional compilation at the end.

Member Avatar for vijayan121
0
7K
Member Avatar for Suzie999

Yes, you're probably screwed. Consider using source code version control in the future. As a last ditch effort, you can check your autorecovery backup files for the project. It depends on your OS, but the folder is under your documents. For example, on my Windows 7 machine it's: C:\Users\jdaughtry\Documents\Visual Studio …

Member Avatar for Suzie999
0
163
Member Avatar for saurabh.mehta.33234

> In any instance, the purpose of the response really seems to be to get the signature displayed in the thread. Yup, and that's against the rules.

Member Avatar for saurabh.mehta.33234
0
92
Member Avatar for alex.mccoy.3386

> double DivSales::totalCorpSales = 0; Move this line into the implementation file for your DivSales class.

Member Avatar for alex.mccoy.3386
0
346
Member Avatar for glenwill101
Member Avatar for glenwill101
0
3K
Member Avatar for lewashby

> As long as the numbers are recorded as int and not as string or array of chars, getNrDigits provides the correct answer. cout << getNrDigits(0) << '\n';

Member Avatar for lewashby
0
434
Member Avatar for deceptikon

C++ conversion of [this C snippet](http://www.daniweb.com/software-development/c/code/445012/simple-interactive-menu) for a simple interactive menuing system. The code shows three files: * menu.h: The header file for the menu class. * menu.cpp: Implementation of the menu class. * main.cpp: A sample driver that uses the library. The menu library is fairly generic in that …

Member Avatar for tinstaafl
2
3K
Member Avatar for amit43

`O(mn)` where `m` is the number of integers you process and `n` is the number of bits in an integer. How did I figure that out? The outer loop is obviously `O(n)`. The inner loop is also obviously `O(n)` and adds to the outer loop, but the value of `n` …

Member Avatar for vijayan121
0
125
Member Avatar for Viped
Member Avatar for Bchandaria

> can any one help me out to identify this problem? Do you have a time machine that can take you back to 1990? If not, you'll have to wait until someone happens by who remembers how to use your ancient compiler.

Member Avatar for deceptikon
0
139
Member Avatar for Elixir42

I haven't experienced that. Sometimes when I'm working quickly it takes the highlighter a second or two to catch up, but other than that it works immediately.

Member Avatar for Ketsuekiame
0
204
Member Avatar for Carolin

> i just ask how can i do that program ? Please read [our rules](http://www.daniweb.com/community/rules) concerning homework, then ask a *specific* question. By the way, "How do I do it?" is silly and unproductive because obviously the answer is you think about the problem, devise a solution, and write code …

Member Avatar for CGSMCMLXXV
0
137
Member Avatar for yunniesshi

Please see my response to your other thread on the exact same project: http://www.daniweb.com/software-development/c/threads/445335/convert-list-into-a-dictionary-using-open-hashing-cursor-based#post1919485 The key is the tutorial I linked you to, as it covers a whole lot of *everything*.

Member Avatar for deceptikon
0
259
Member Avatar for prakhs

> There is an error while using 2nd stack. how to debug it. Start by telling us the error and line. Here, I'll help. This error occurs on line 173: 'void Stack<long double,50>::push(T &)' : cannot convert parameter 2 from 'long double' to 'long double &' And it has nothing …

Member Avatar for prakhs
0
943
Member Avatar for bazzer14

I'm sure everyone is familiar with this random piece of disassembled code. :rolleyes: Do you have an actual question that I'm not likely to answer with "go read a book on assembly language"?

Member Avatar for bazzer14
0
379
Member Avatar for mdbelalp

Sounds like a kernel panic and automatic reboot. Are you using Windows? The first thing I do on a new Windows install is go into the startup and recovery options of advanced system settings, then disable the option to automatically restart on a system failure. That way when the fault …

Member Avatar for stormal1
0
120
Member Avatar for andy91

> How do you organise yourself when working on a project? It really depends on the project. Some are small enough that strict organization is unproductive or even counterproductive. Others are large/complex enough to warrant full bug and feature tracking system and a formal development life cycle. For inbetween projects …

Member Avatar for andy91
0
277
Member Avatar for tony75

If the total amount is greater than $399, multiply it by .9 to get the total after a 10% discount. Otherwise, if the amount is greater than $199, multiply it by .95 for a 5% discount. Otherwise, don't make any changes: // Apply discounts if (total > 399) total *= …

Member Avatar for tony75
0
200
Member Avatar for Rahul47

The only real problem I see in that line is your query isn't correct. You still need to add single quotes *in the query* to make string values SQL strings. It helps to copy the string verbatim into Management Studio (or whatever database utility you use), replace the VB.NETisms and …

Member Avatar for Rahul47
0
400
Member Avatar for MasterHacker110

> What does it help to make a class object as a pointer? In your code it doesn't matter, but there are a number of reasons you might want or need a pointer. Dynamic allocation comes immediately to mind as a case where you need a pointer. > and also …

Member Avatar for Moschops
0
155

The End.