Search Results

Showing results 1 to 40 of 1000
Search took 0.11 seconds.
Search: Posts Made By: VernonDozier ; Forum: C++ and child forums
Forum: C++ 4 Days Ago
Replies: 5
Views: 223
Posted By VernonDozier
Once a stream has failed, it will stay failed until it is cleared, so if you were to take this approach, you'd have to clear the stream at the top of the loop.
...
Forum: C++ 4 Days Ago
Replies: 5
Views: 223
Posted By VernonDozier
There will be no looping. 1 will be accepted as input. 3556 will remain in the stream. id will be assigned to be '1', which in Acscii is 49. Your solution deals with illegal input just fine, but...
Forum: C++ 4 Days Ago
Replies: 5
Views: 223
Posted By VernonDozier
The stream will fail on line 37 if something that is not a digit or a minus sign (or possibly a decimal? Can't remember) is entered. Once the cin stream is in a failed state, if you do not clear...
Forum: C++ 8 Days Ago
Replies: 1
Views: 170
Posted By VernonDozier
There's MySQL, there's C++, and there's how to use MySQL from C++. I've used MySQL++ as a wrapper successfully to do this, but that was a while ago, so I don't remember the ins and outs. The first...
Forum: C++ 14 Days Ago
Replies: 8
Views: 373
Posted By VernonDozier
I'm not the one assuming. You're assuming that it was a professor who gave the code as a debugging exercise and that anyone reading your post would know that "fixed" meant that "it now compiles and...
Forum: C++ 14 Days Ago
Replies: 8
Views: 373
Posted By VernonDozier
I understand exactly what's going on here. I've been doing this for quite a while and I've dealt with lots of beginners and first-time posters. I'm not assuming I know what he wants. I have no idea...
Forum: C++ 14 Days Ago
Replies: 8
Views: 373
Posted By VernonDozier
UberJoker, don't be so judgmental. The original code definitely had some problems, but we've all seen much, much worse. And the code you posted still has lots of problems. It's "fixed" in that it...
Forum: C++ 19 Days Ago
Replies: 5
Views: 361
Posted By VernonDozier
If you don't get any of the lines that I added as cout statements, that means that they aren't being executed even once, so it's breaking somewhere, and very early.

Whether the code is the problem...
Forum: C++ 19 Days Ago
Replies: 6
Views: 258
Posted By VernonDozier
One, if you are new to C++, I would suggest not using C-Strings at all for this. C-Strings require you to adjust the null terminator. Regular strings do not. You use both in this program. It's...
Forum: C++ 20 Days Ago
Replies: 6
Views: 489
Posted By VernonDozier
Line 72:


while((t!=9&&w==0)&&((t!=9)||((w==0))));


Even if it is correct, it definitely looks overly complex. Maybe this?


while (t < 9 && w == 0);
Forum: C++ 20 Days Ago
Replies: 6
Views: 258
Posted By VernonDozier
Again, use code tags. See post 2 for how. Code is hard to read otherwise.

You got rid of the k++ line, so now k is always 0. Accident? What is this program supposed to do? If you have a...
Forum: C++ 20 Days Ago
Replies: 6
Views: 258
Posted By VernonDozier
Code tags:



// code goes here



So ARRAY_SIZE is 25? 26? Is it defined somewhere? It's not listed here, and a lot of other stuff isn't listed either, so it's impossible to run and it's...
Forum: C++ 20 Days Ago
Replies: 5
Views: 361
Posted By VernonDozier
I formatted the code to make it easier to read and added a few lines - see "Added by VD" in comments. cin.get() pauses so you have time to read. Press the "Enter" key to move on. Delete later. ...
Forum: C++ 23 Days Ago
Replies: 2
Views: 234
Posted By VernonDozier
The posts got messed up somehow so you have some truncated code, two triangle.h files, and no virtual.cpp function. Please repost using code tags:



// paste code here



...
Forum: C++ 27 Days Ago
Replies: 11
Views: 407
Posted By VernonDozier
Here's the normal layout I use (changed as needed, but pretty standard):


// #include statements go here
// "using namespace std" (if desired) here
// #define statements here
// global...
Forum: C++ 27 Days Ago
Replies: 13
Views: 463
Posted By VernonDozier
Thinking about my earlier mention of "map", while I don't think that "map" would work for you here, I'm wondering whether multimap or perhaps something else from STL might be useful to you here. ...
Forum: C++ 27 Days Ago
Replies: 13
Views: 463
Posted By VernonDozier
My advice is to create both classes that I suggested:


class Merchandise
{
string product;
double price;
};

class GroupedMerchandise
Forum: C++ 27 Days Ago
Replies: 6
Views: 398
Posted By VernonDozier
I'd confirm this if I were you. Until you've verified that it will work on all compilers, assume that it won't. Maybe it does. I've never seen this. I've always set up a loop and gone through the...
Forum: C++ 27 Days Ago
Replies: 13
Views: 463
Posted By VernonDozier
That's an associative array. They exist in some languages (i.e. PHP), but they don't exist in C++. A "map" would be a C++ alternative to an associative array.
...
Forum: C++ 27 Days Ago
Replies: 10
Views: 2,637
Posted By VernonDozier
What on Earth does this post mean and what does it have to do with prime numbers?
Forum: C++ 27 Days Ago
Replies: 6
Views: 398
Posted By VernonDozier
I've never seen this syntax before:


char array[MAX_SIZE] = {};


Does that initialize all of the elements to zero? If so, I've just learned something new. I've never seen '\0' used to...
Forum: C++ 28 Days Ago
Replies: 11
Views: 407
Posted By VernonDozier
This function:


bool checkQuestion (bool boolAnswer)
{
if (boolAnswer)
return true;

return false;
}
Forum: C++ 28 Days Ago
Replies: 11
Views: 407
Posted By VernonDozier
The syntax highlighting is fine. The indentation boggles the mind. This is much more readable:


if (a == b)
{
// do stuff
}
else if (a == c)
{
// do other stuff
Forum: C++ 28 Days Ago
Replies: 6
Views: 398
Posted By VernonDozier
Lines 15 - 24 - This loop is a black hole. Once you get to line 23 the first time, if you get to it, you'll never get out. Well, you'll get out when you go through it MAX_SIZE times, so that's a...
Forum: C++ 29 Days Ago
Replies: 5
Views: 269
Posted By VernonDozier
You need a way to tell whether a string is a number or not. Define exactly what a "number" is (negatives, decimals, commas, just digits, etc.), then you can write a function to test a string. If...
Forum: C++ 29 Days Ago
Replies: 8
Views: 270
Posted By VernonDozier
"Voila! Syntax-highlighting!" isn't part of the code tag. niek_e is just excited by the power of code tags and decided to spread the enthusiasm. Feel free to replace "Voila! Syntax-highlighting!"...
Forum: C++ 30 Days Ago
Replies: 14
Views: 496
Posted By VernonDozier
You need to meet more C++ programmers then. Custom namespaces are all over the place, for good reason. I just debugged my own (very short) project. The culprit? I had several functions called...
Forum: C++ 30 Days Ago
Replies: 11
Views: 436
Posted By VernonDozier
You CAN "return" more than one value. "Return" is in quotes on purpose. Pass the row and column by reference (denoted by &).


int findMax(int grade[][20], int& row, int& column)
{
// same...
Forum: C++ 30 Days Ago
Replies: 11
Views: 436
Posted By VernonDozier
You should post your updated code and explain exactly what your present problem is. You've made a lot of revisions, but no one knows what they are.
Forum: C++ 31 Days Ago
Replies: 2
Views: 237
Posted By VernonDozier
Stringstreams will work wonders here. Let the >> and << operators do all the parsing and type changing work for you.

http://www.cplusplus.com/reference/iostream/stringstream/
Forum: C++ 31 Days Ago
Replies: 25
Views: 1,659
Posted By VernonDozier
He just gave you the entire program and now you want comments (very nice program by the way, sfuo. It works well). Why don't you go through the code, figure out how it works, and after you do,...
Forum: C++ 31 Days Ago
Replies: 25
Views: 1,659
Posted By VernonDozier
I'm looking at the post times. This one comes two posts after firstPerson's post. Quite fast. I wouldn't "get it" either if I had to learn the Insertion Sort in two minutes. Since it uses an...
Forum: C++ 31 Days Ago
Replies: 25
Views: 1,659
Posted By VernonDozier
"Simple", "efficient", "correct", and "not tedious" are different concepts. Your "easiest", most brain-dead method is to make 120 "if" statements, not taking advantage of the results of previous...
Forum: C++ 32 Days Ago
Replies: 25
Views: 1,659
Posted By VernonDozier
Five numbers can be ordered 5! or 120 ways. The no-brainer way of writing this code would thus be writing an if statement with 119 "else if" statements, one for each possible ordering. You should...
Forum: C++ 33 Days Ago
Replies: 10
Views: 526
Posted By VernonDozier
It seems to fluctuate between 0.03 and 0.08 seconds for me. I don't know enough about scheduling algorithms to know what would cause that fluctuation, or if that would be a factor in programs that...
Forum: C++ 33 Days Ago
Replies: 10
Views: 526
Posted By VernonDozier
Impossible to know without knowing what the code does and without knowing what else might be competing for your computer's resources while running the program, some of which might have a higher or...
Forum: C++ 34 Days Ago
Replies: 2
Views: 310
Posted By VernonDozier
You have number declared as an integer, but you are treating it as a string. There is no "int" class, so you cannot use the dot operator as you do in line 17. Use an if statement instead of the...
Forum: C++ 34 Days Ago
Replies: 10
Views: 526
Posted By VernonDozier
According to Ark M in this thread, if you want microseconds, you need something OS-specific.

http://www.daniweb.com/forums/thread134643.html

Ancient Dragon's idea in this thread is to do...
Forum: C++ Nov 14th, 2009
Replies: 2
Views: 216
Posted By VernonDozier
There are two separate terms to think about: "size" and "capacity". "capacity" is the storage allotted to the array. "size" is the number of elements in the array THAT YOU CARE ABOUT. The main...
Forum: C++ Nov 14th, 2009
Replies: 2
Views: 462
Posted By VernonDozier
If you do not know the size ahead of time, you can use the MAXIMUM size to make sure you have now overflow. There is no maximum size for this. There's a maximum number of columns, but not a maximum...
Showing results 1 to 40 of 1000

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC