3,183 Posted Topics
Re: The questions you've asked are the purpose of the "How would you test a toaster" interview question: [list] [*]Can you think logically through the requirements for the toaster? [*]Can you devise testing steps that put the requirements through their paces? [*]Can you think of plausible edge cases that weren't considered … | |
Re: I think the calculations are too complicated. Try this: [code] // Get the total months for full years worked tm = (eyear - syear) * 12; // Remove months not worked from the first year tm -= (smnt - 1); // Add months worked from the last year tm += … | |
Re: This Daniweb tutorial explains what is happening and how to fix it: [URL="http://www.daniweb.com/software-development/cpp/tutorials/90228"]"Flushing" the input stream[/URL] | |
| |
Re: It took a surprising amount of work to get Dani to put that tiny forum index link at the bottom of every page, so I'll ask what she'll probably ask. Why do you need to get to the index so badly that there has to be an immediate link from … | |
Re: [QUOTE]Now i know what is cout for but what is std and what are these "::" for?[/QUOTE] The :: operator is called the scope resolution operator. It's primarily there for accessing names declared in a namespace or class, and std is the C++ library's namespace. std::cout says to look for … | |
Re: 1) Other. Mostly books, reading code, answering questions about code, and experimenting. 2) Interested. 3) No, I learned C first. 4) Yes, I've learned many languages after C++. | |
Re: [QUOTE]The way I see things, constantly calling fact(n - 1) when the method tries to return will result in an infinite amount of times the method being called without returning anything.[/QUOTE] Each call invokes a new instance of the function with new arguments. The effect is as if you did … | |
Re: Close, don't forget 0. It makes all the difference. :) It's also possible to use a trick with strings and avoid typing out the whole array: [code] char const* hex = "0123456789ABCDEF"; // get the least significant digit in hex char digit = hex[value % 16]; [/code] | |
Re: [QUOTE]did I miss something here??[/QUOTE] There are too many variables named t. There's the global t and the local t in main()'s loop. It's recommended not to use the same name more than once for nested scopes. It's very easy to get confused. | |
Re: [QUOTE]The Programm stops at line 325 - 331[/QUOTE] The array is being indexed with timer0, but the rest of the loop suggests that it should be using timer2. I'd guess that timer0 is out of bounds for the array, which is one of the big causes for a segmentation fault. | |
Re: [ICODE](*eq->pt_tree[0]) = 2;[/ICODE]. | |
Re: Try [ICODE]--(*eq->pt_tree[c]);[/ICODE]. | |
Re: [QUOTE]which is the best programming language between java and .net.[/QUOTE] .NET isn't a language, it's a framework. You probably mean Java and C# as they're very similar in terms of syntax, but it's still impossible to compare languages without a very specific context and well defined points of comparison. Just … | |
Re: If there are more reads than writes, any reads beyond the number of writes will fail. If there are more writes than reads, nothing happens aside from a risk of lost data for the writes that weren't consumed. | |
Re: Only Dani can undo reputation, to the best of my knowledge, as it's not built into the vBulletin interface even for community admins. However, you can negate it by waiting until tomorrow and then applying positive rep to another post. It's not perfect, but at least that would make the … | |
Re: [QUOTE=drico7041;1753322]Do you have to be like a master programmer in a certain language to land a job in this field?[/QUOTE] Of course not. The idea that professional developers are always masters of the craft is a romanticized fantasy that hobbyists dream up. The reality is that only a small fraction … | |
Re: [QUOTE]is there any other function that would including the end line character?[/QUOTE] [code] istream& my_getline(istream& is, string& s) { istream& result = getline(is, s); s.push_back('\n'); return result; } [/code] Presto! | |
Re: Depending on the topic of your threads, I'd say one of the Microsoft Windows sub-forums or Web Development sub-forums would be the best fit as it stands now. Adding a forum isn't technically a huge deal, but there needs to be sufficient demand first. Otherwise we'd end up with the … | |
Re: [CODE]template<typename T> Point<T> Point<T>::plus(Point<T> operand2) { Point temp; temp.set_x(get_x() + operand2.get_x()); temp.set_y(get_y() + operand2.get_y()); return temp; }[/CODE] | |
Re: Does the string represent a valid double value? If not, then you won't find a conversion function that works without first getting a library that supports larger floating point values. | |
Re: Nobody is going to do your homework for you. Please read our rules and then ask a specific question about the problem if you need help. And by help, I mean a little help, not giving you the answers. | |
Re: I see a bunch of potential problems, but in my environment the file reads perfectly. I don't want this post to be completely useless to you, so here is a test program that just reads the file and displays the lines in the vector. I fixed the aforementioned potential problems … | |
Re: [QUOTE]If you say a post is good or bad, you always have to why.[/QUOTE] Voting is completely anonymous outside of a direct database query, which only Dani presently has access to perform. With the current vBulletin back-end, reputation is not anonymous, but a comment isn't required. As best practice I'd … | |
Re: You can initialize present to '\0'. That won't compare equal to whitespace or any of you word boundaries, and it will immediately be reset to whatever the first character is. | |
Re: I see a few problems with the sorting algorithm: [QUOTE][CODE]int p = o - 1;[/CODE][/QUOTE] When the loop first starts, o is 0, but the next thing the code does is compare values[p] with values[p + 1]. That's the same as saying [ICODE]values[-1] > values[0][/ICODE], which is an out of … | |
Re: What kind of flexibility do you have in the file format? If it doesn't need to be human readable outside of the reading application, you could store records in the insertion order for a binary search tree. That way there's no mucking about with sorting, it all happens naturally through … | |
Re: I think a good question to ask is why do you think you need this behavior? Even in C# it's recommended to avoid ArrayList in favor of the more statically typed generic List<>. C++ isn't designed with a universal Object class that everything derives from, which makes a heterogeneous collection … | |
Re: [QUOTE]What's a nod? What's an edge? What's a weight?[/QUOTE] Nod is obviously a typo for node, and all of those terms are well known in graph theory, as is Prim's algorithm. I don't think the OP is expected to explain concepts that should be common knowledge, and I'm assuming you're … | |
Re: This looks like a normal homework assignment that combines previously learned tasks into a complete application: [list] [*]Generating random numbers [*]File I/O [*]Searching [*]Sorting [/list] The only part that might not have been covered in your class would be computing the CPU time, but that's straightforward. I'll give you that … | |
Re: Or the less redundant: [code] repeat1 = true; while (repeat1) { cout << "Would you like to add another item? (Y/N): "; cin >> addAnother; repeat1 = (addAnother == 'y' || addAnother == 'Y'); } [/code] Note that I fixed the condition for checking against 'y' or 'Y'. Before it … | |
Re: Here are the formulae for converting between Fahrenheit and Celsius: Celsius = (5.0 / 9.0) * (Fahrenheit - 32) Fahrenheit = (9.0 / 5.0) * Celsius + 32 Once you have the values for Celsius or Fahrenheit, just plug in the formula at the appropriate place and display the result. | |
Re: C++ isn't an easy language to learn. [URL="http://www.amazon.com/Accelerated-C-Practical-Programming-Example/dp/020170353X"]This book[/URL] is as close to a modern introduction as you'll find, but it's starting to show some age. The new standard came out recently, but I don't know of any books focusing on it yet, much less beginning books. | |
Re: [QUOTE]As the title says, Python or Ruby?[/QUOTE] In what context? For what purpose? What metrics are you looking to compare? It's impossible to compare languages without a very specific target of comparison. Just asking "which is better?" will get you nothing but useless subjective opinions. | |
Re: [QUOTE=ohblahitsme;1750312]Thanks for the reply WaltP, but I don't have an .EXE file. I'm running a.out from the terminal in order to execute my program.[/QUOTE] a.out [i]is[/i] the executable file. Look in the same directory as a.out, or the current working directory when you run your program. | |
Re: How is 'string' defined for this purpose? Technically any text file only has one string, the entire contents of the file. Another common method is reading words where a 'word' is any unbroken sequence of non-whitespace characters. | |
Re: [QUOTE]Those seniors told me the codes have many factors of "history", every line have their "meaning", but when I ask them--those seniors of our company, they know nothing and have not ideas what is wrong with these codes.[/QUOTE] You're treading on dangerous ground. It's very important not to think of … | |
Re: When you say [ICODE]ch=i++[s];[/ICODE] it means [ICODE]ch=(i++)[s];[/ICODE], but when you say [ICODE]ch=++i[s];[/ICODE] it means [ICODE]ch=++(i[s]);[/ICODE]. It's totally confusing because intuition says it should be [ICODE]ch=(++i)[s];[/ICODE]. But that's where the '!' is coming from. i is 3 at that point, and the next character after ' ' in ASCII is '!'. | |
Re: Web design these days is more about dynamic pages than static, so you probably won't just be using HTML and CSS. Using things like Javascript, PHP, ASP, and databases is a lot easier when you have some programming experience. If you can't work with those technologies, you could probably still … | |
Re: The standard uses a simpler description: [QUOTE]if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.[/QUOTE] | |
Re: gallon is used as the loop controller, but you never change its value in the loop body. This is called an infinite loop. | |
Re: It alternates characters just fine for me, but you can simplify the toggle just by flipping a variable instead of trying to calculate it based on the loop indexes: [code] #include <iostream> #include <windows.h> using namespace std; int main() { HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE); int basecolor1 = FOREGROUND_GREEN | FOREGROUND_INTENSITY; … | |
Re: A busy wait loop will task the CPU while putting the thread to sleep will not. If you need a short sleep to let the connection close completely then Thread.Sleep() is the way to do it. | |
Re: There's no choice but to use a loop somewhere. You can hide it behind a function, or use a compiler-specific function like strlower(), but there's still a loop. | |
Re: wordCount() is ruining the string for later processing. Always remember that strtok() modifies the string by writing '\0' at appropriate places. What about merging the two tasks of counting words and saving them to the array? [code] #include <iostream> #include <cstring> using namespace std; namespace { const int MAX = … | |
Re: What does your manipulator look like? | |
Re: The only real duplication you have is in printing the too many days error. Any other overcomplication comes from parsing two dates at the same time. I think a better option is a function that parses one date, then call it twice. | |
Re: The C++ runtime eventually has to call your main(), but there's stuff that needs to be done both before and after. Judging by the name, you're using a Microsoft compiler. If you have the CRT sources then look for crt0.c, it's a small source file that does the runtime initialization. |
The End.