6,741 Posted Topics
Re: CountDown::end() doesn't return anything yet you declared it to return bool. That makes you a liar. ;) | |
Re: [B]>else DIR * mydir = opendir(dir);[/B] Note the [ICODE]else[/ICODE] without braces. This means you have an else clause with one statement that defines a variable and then immediately destroys it. It's as if you had braces like so: [code] else { DIR * mydir = opendir(dir); } [/code] [ICODE]mydir[/ICODE] doesn't … | |
Re: [QUOTE]The codes generated by template are same as handcrafted codes, so what makes template being blamed by code bloat if you know how to handle it properly?[/QUOTE] Nothing, [U]if[/U] you handle it properly. Most of the time there's a lack of understanding about how templates work, ignorance of the solutions … | |
Re: There's a link at the bottom of every page (under the About Us, Contact Us, etc.. links) that will take you back to the forum index. | |
Re: [B]>if(letter_counter == '\n') //|39|error: ISO C++ forbids comparison between pointer and integer|[/B] [ICODE]letter_counter[/ICODE] is an array of char, but '\n' is a single char. When arrays are used in value context they're converted to a pointer to the first element, so your comparison types are [ICODE]char*[/ICODE] and [ICODE]char[/ICODE], which are … | |
| |
Re: There's no sorting going on in your code. Any ordering is coming from the files themselves. | |
Re: [B]>stream.seekg(7, ios_base::beg);[/B] seekg() is for adjusting the read pointer. You want seekp() to adjust the write pointer. | |
Re: && has higher precedence than ||, so the evaluation looks like this: [code] if ( (initialize == "off" && Iminor > 20) || Imedium > 10 || Isevere > 5 || Ifatal > 0 ) [/code] When what you really want is this: [code] if ( initialize == "off" && … | |
Re: We don't give away code so that students can cheat on their homework. If you want to put forth some effort in writing this program you'll find help here, otherwise the thread will be in violation of Daniweb's rules and be either closed or deleted. | |
Re: Does the string need to represent a valid value for a specific integer type? Or are you just looking for digit characters and possibly a sign? | |
Re: Use a second stack. Pop each item off of the first stack, push them onto the second stack, then pop items off the second stack and print them until it's empty. | |
Re: There has to be some conversion. The two operands need to be converted to an integer type, and then the result of addition needs to be converted to a string. For example using boost::lexical_cast for brevity: [code] string string3 = boost::lexical_cast<string>( boost::lexical_cast<int>(string1) + boost::lexical_cast<int>(string2)); [/code] boost::lexical_cast is basically just a … | |
Re: [QUOTE=cmccaig;1561153]he may of meant char answer= ''Y''N''; ^ something like that so that when its printed to console its separated by '[/QUOTE] And what [U]character[/U] would that represent? | |
Re: It looks to me like you should be tokenizing the string into fields first, then using a specific field as the comparison data. std::sort() takes a third argument as a predicate, if you want to customize the comparison method: [code] #include <algorithm> #include <fstream> #include <iostream> #include <string> #include <vector> … | |
Re: Unless the lines have a fixed column width, you have little choice but to read and discard lines until reaching a certain count: [code] #include <stdio.h> /* Get the nth line (1-based) from the current read position */ int get_nth_line(FILE *in, char *buf, size_t size, size_t n) { size_t i … | |
Re: [QUOTE]no in a console in visual studio 2010[/QUOTE] That's a Windows environment, unless Visual Studio was made portable across platforms without my knowledge. :icon_rolleyes: | |
Re: You have the right idea already, just extend it for all characters instead of just the alphabet. Then you can either process the frequency array later to get the count of non-alphabetical characters, or keep a running count if you wish: [code] #include <ctype.h> #include <limits.h> #include <stdio.h> int main(void) … | |
Re: [iCODE]break[/iCODE] and [iCODE]continue[/iCODE] work for any loop. | |
Re: [QUOTE]All identifiers starting with one or two underscore characters are reserved for the compiler vendors for use in their implementation (of either the standard libraries or language extensions, or both).[/QUOTE] Just a minor nit, since I feel the need to defend my own naming convention. ;) What you've said is … | |
Re: [QUOTE]no body seems to help[/QUOTE] Your idea of help doesn't correspond to ours. "Help" does not mean "write it for me". | |
Re: Look at your "overloaded" constructor. Does it allocate memory? Does it dereference the pointer as if memory were allocated? | |
Re: [QUOTE]What tutorial would you recommend?[/QUOTE] I recommend [URL="http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx"]this one[/URL]. The code is in C, but mostly relevant to C++. Pretty much the only thing that needs to be changed to compile as C++ is adding a cast to malloc calls. | |
Re: [URL="http://msdn.microsoft.com/en-us/library/ms680582%28VS.85%29.aspx"]Clicky[/URL]. | |
Re: You're neglecting to account for the subtraction of '0' (with an integer value of 48, in this case): c = 49 0 * 10 == 0 0 + 49 == 49 49 - 48 == 1 Next character: c = 50 1 * 10 == 10 10 + 50 == … | |
Re: The overload of m_pParent->Log() you're calling isn't defined anywhere that the compiler can see. To start, make sure it has a definition for the type and number of arguments you're passing. | |
Re: Did you search the forum? Did you search google? I bet you didn't, because such an example is trivial to find. People are generally less friendly when they have to answer the same question for the umpteenth time because you're too lazy to put in a little effort in helping … | |
Re: [QUOTE]When I use the length() function it only counts the characters from the first word.[/QUOTE] The problem isn't getting the string length, that's correct. The problem is that the way you're getting input stops at the first whitespace. So when you type "hello world", the string only contains "hello" and … | |
Re: [QUOTE]b)assign a newly created dynamic array of 99999 pointers of X to w. [CODE]w=new &&X[99999];[/CODE][/QUOTE] Erm, close. Let's start with s first: [code] s = new X[99999]; [/code] The difference between s and w is one level of indirection, so the new[] expression should reflect that in the type: [code] … | |
Re: [QUOTE]Huh? I thought endianness is HW-dependent, not OS-dependent.[/QUOTE] That's true at the OS vs. CPU level, but it's more of a practicality than a requirement. While the processor runs in a specific endian mode (some can even switch between modes), endianness at any higher level is really about performance and … | |
Re: Type a string, then hit enter, then type a space and hit enter again. That'll get you through the maze of ignores. ;) What exactly are you trying to accomplish here? | |
Re: [QUOTE]Should I rather work out late at night before bed, or early in the morning right after I wake up?[/QUOTE] Work out at the time that is most convenient for your schedule. I go to the gym after work for about an hour because that's the most convenient time. [QUOTE]you … | |
Re: [code] string cmd("mkdir \"/Users/" + user + "/Library/Application Support\""); system(cmd.c_str()); [/code] | |
Re: Thanks for the post, IcantC, but take note that this thread is four years old. Perhaps your expertise would be better spent on current threads? :) | |
Re: [QUOTE]Now from what I have heard bubblesort are not efficient for large sets of data, is it true?[/QUOTE] For the most part, yes. For the quadratic sorts, insertion sort is a better choice, though [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/qsort/"]qsort from <stdlib.h>[/URL] should be the first algorithm you turn to since it's highly likely to … | |
Re: You can do this with two variables: one for the first value in a matching sequence and one for the current value. As long as they match, increment your counter. When they don't match, print your result for the sequence, reset the counter to zero, and set and the first … | |
Re: Run it as a background process: [code] $ ./myprog & [/code] I'm not 100% with OS X, but in theory this should work since Darwin is based on Unix. | |
Re: Shall we start with MyQueue::pop_front() being completely nonsensical? You always return queue[100], and 100 isn't even a valid index in the array. | |
Re: Excepting leap years, a month could have 28, 30, or 31 days. Your Date object contains the month, so you can use that to determine how many days there are in the preceding months quite easily using either a switch or table lookup. For example, you want to know how … | |
Re: [QUOTE]when I updated to Xcode 4 I have problems[/QUOTE] You and everyone else. Did you hear that Apple's bug reporting server crashed after they released Xcode 4 due to the load? | |
Re: [QUOTE]3: Are you posting in the most appropriate place to receive relevant replies? This is the C++ Forum. YES[/QUOTE] This doesn't strike me as a C++ question in the slightest, actually. | |
Re: I'm going by your comment rather than the vague "it's failing out": [B]>perc[i] = (votes[i] / sum) * 100;[/B] So votes[i] and sum are both integers. Keeping in mind that any precision will be truncated, you probably wanted this instead: [code] perc[i] = (votes[i] / (double)sum) * 100; [/code] By … | |
Re: So you're receiving emails with an account you don't have? ;) Assuming the emails are going to the current account in your control panel (otherwise you wouldn't be getting them) and the "wrong" email is informational, it's probably the email address you registered with in the first place in 2004. | |
Re: Is there any reason why you can't use double instead of int in the first place? That way the conversion would be unnecessary. | |
Re: [QUOTE]is itsVal in the Add function VarOne and the initialized (2) from the Counter::Counter(int initialValue): itsVal(initialValue) {}constructor?[/QUOTE] Yes. [QUOTE]and is it added to a const Counter reference of VarTwo?[/QUOTE] No, VarOne::itsVal is added to VarTwo::itsVal, and that result is used to initialize a Counter variable for return from the Add … | |
Re: [QUOTE]Now when i look at it, i feel everything can be done using a 1-d array and incrementing the pointer appropriately.[/QUOTE] Just because you [i]can[/i] do something doesn't mean it's always the best way. | |
Re: [QUOTE]i dont know about command line arguments in OOP[/QUOTE] There's nothing OOP about it. main() takes two parameters: an integer containing the count of arguments, and an array of pointers to char containing the string value of each argument: [code] #include <iostream> using namespace std; int main(int argc, char *argv[]) … |
The End.