6,741 Posted Topics
Re: >For some reason, it crashed right here. The only reason for a crash there is if listOfLists can't be dereferenced (if it's NULL, for example). | |
Re: It has to be compatible with the slot, but how does this have anything to do with software development? | |
![]() | Re: >Cant figure out why. Um, because you're using those two variables before giving them a value. >int hours, rate_of_pay, salary_with_overtime, salary_without_overtime; >salary_without_overtime = rate_of_pay * hours; >salary_with_overtime = (40 * rate_of_pay) + ((hours - 40)* 1.5 * rate_of_pay); Look at the first line, then look at the next two lines … |
Re: >I would like to have a general format that would >produce such arrays for any given parse tree. It looks fairly simple. Just recursively traverse the tree and save the paths as you go: [code=c] #include <stdio.h> #include <stdlib.h> struct node { int data; struct node *link[2]; }; struct node … | |
Re: >could someone please tell me what I need to use for this? Something besides char* because you obviously don't know what you're doing. I'd suggest using the string class, then you can use the c_str member function to get a pointer to const char for your hash function. | |
Re: >i am sry..i was in ahurry.. I think you're still in a hurry. Slow down, compose a coherent post with correct spelling and grammar, then you can use "in a hurry" in the past tense. | |
Re: Try [url=http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx]this tutorial[/url]. Though I get the sinking feeling that it's not suited for you. :icon_rolleyes: | |
| |
Re: No. Read our rules about keeping help on the site. | |
Re: >I see every new member as a potential regular member, if given the chance. I wonder what would happen if we took a month's worth of statistics on new members, then after another month see how many of those members are still active. Do the same after six months and … | |
Re: >I have searched the webb but can't find a solution for it. Then how do you know it's an easy problem? My guess is that you didn't look very hard, because the answer can be found easily. >ch is a const char ch, as u can see. Yes, I can … | |
Re: C++: [code] #include <iostream> int main() { std::cout<<"Hello, world!"<<std::endl; } [/code] Euphoria: [code] puts(1, "Hello, world!\n") [/code] Forth: [code] : HELLO ." Hello, world!" CR ; HELLO [/code] Java: [code] class hello { public static void main(String [] args) { System.out.println("Hello, world!"); } } [/code] C#: [code] using System; class … | |
Re: Not anybody, but I'm sure somebody does. | |
Re: Your code shouldn't compile at all because you haven't terminated the structure definition with a semicolon. >date.d = atoi(str_date.substr(0,2).c_str()); >date.m = atoi(str_date.substr(2,3).c_str()); >date.y = atoi(str_date.substr(4,7).c_str()); substr doesn't use a begin/end pattern, it uses a begin/count pattern. The second argument should be 2, 2, and 4 for those three lines, respectively. … | |
Re: >I want to know if that's a good idea, or what to look out for. If your goal is C++, there's little point in side tracking yourself with C. But do keep in mind that C and C++ require different mindsets. Good C isn't necessarily good C++, and vice versa. … | |
Re: >I'm using TC++ 3.0. Why? >I think that the compiler is faulty. And? Salem agreed with you [b]if[/b] the code you posted is exactly the code you're running. What more are you looking for? | |
Re: >So, by now it seems like C++ will be the futures programming language. Why? If it really seems that way then you should be able to point out a list of convincing reasons. >But what do you think of the future of programming languages?? I don't really care. As programming … | |
Re: >It should be protected rather than public. The Employee members. No, it should be private. Just pretend that it's illegal to have protected data members. >If someone could explain to me how to go about fixing this problem it would be awesome! Add a protected member function that gives child … | |
Re: >I tried something but it didn't work. I tried something and it did work. I guess the problem is with your code somewhere between the beginning and the end. | |
Re: >what/where could I use a hash table (chaining?) in my program. That's ass backward. It's a solution looking for a problem, not a problem looking for a solution. | |
Re: If you get banned from this forum, you're not likely to last long on PFO. We're far less forgiving over there. | |
Re: >My compiler says my code isnt standard c++? Your compiler is right. >#include <iostream.h> Some people will try to tell you iostream.h is deprecated, but they're wrong. It was never standard to begin with. Since you clearly think you're using the standard iostream anyway, you might as well just hack … | |
Re: >char date1 = "03"; >char date2 = "06"; >char date3 = "2007"; >char new string; None of these are strings in C. Your syntax is way off. >what I need is new string like: >new string =03-06-2007.txt Look up sprintf. You can also use strcat if you want a more … | |
Re: Check your spelling, check the number of arguments, check the type of arguments, and if none of that works, make a tiny program that exhibits the problem so that we can actually compile and link it ourselves instead of trying to decipher the snippets that you [i]think[/i] are relevant. | |
Re: Or you can use stringstream and getline with ':' as the delimiter. That's generally easier to get right: [code=cplusplus] #include <iostream> #include <sstream> #include <string> int main() { std::stringstream in ( "A:B:C" ); std::string token; while ( std::getline ( in, token, ':' ) ) std::cout<<"Split token: "<< token <<'\n'; } … | |
Re: You're storing the factorials in an array, but that doesn't change how you calculate the value. Do you know how to calculate a factorial? | |
Re: >Both methods throw an exception if you try to enter something other than an integer. How do you figure that? Only the second will actually throw an exception. The first will simply set cin to an error state (in which case the ignore will effectively be a no-op). | |
Re: Let me get this straight. You went through four years of college with a focus on computer science and have [i]no idea[/i] how to build your projects on your own? I hope you didn't pay much for that course, and I'm rather afraid that you're about to enter the workforce … | |
Re: >Do you have to have the studio or C++ express will do? The Visual C++ Express debugger is fully functional. | |
Re: >This is a math problem. No, it's not. Reading the data as an integer strikes me as dangerous in this case. I can easily see integer overflow being a potential problem, and that serious affects the robustness of the code. Something like this would be better: [code=cplusplus] #include <fstream> #include … | |
Re: >i wanna know how to output a B-tree like that: Please don't refer to binary trees as B-trees. A B-tree is a separate data structure with significant differences. As for how to print a [b]binary tree[/b] like you want, you can do it a number of ways. However, that particular … | |
Re: It looks like the input specifies indices of which values are to be set to 1. Let's say you have an array of 10 rather than 100 (because I don't want to type that much). You initialize the array to 0's: [code] {0,0,0,0,0,0,0,0,0,0} [/code] Now let's say the user types … | |
Re: >I started learning C# but I became annoyed at the need for the >.NET enviroment on every machine the program was run on C# has no such restriction. It's a standardized language that can run outside of the .NET framework[1]. However, you're going to find this annoyance everywhere you go … | |
Re: >the line 6 ::is it like declare a varible or pointer or what ?? It's an object definition. stringstream is a class, just like string. >becouse ,when i print ss without str() i see address ,what is that mean?? It means that stringstream doesn't have an overloaded operator<< for stringstream, … | |
Re: >since i do not have any Industrial Experience.. It's a final year project. Just pick something you learned that exhibits your newfound skills and seems interesting. It doesn't have to be practical or viable in the market, so asking for advice from people with "Industrial Experience" is silly. | |
Re: >I was hoping some one could shed some light on the reason this works. Think of it as a normal range shifted to fit your lower bound. When you use x % y, it forces x to be within the range of 0 to y. This corresponds to [ICODE]rand() % … | |
Re: >int card_value, card_face, card_value; >int card_value[4][4]; So, how many variables are you going to try to give the exact same name? >int fill_values(card_value[4][4]); You sure do like the name card_value, but for a function declaration you need to provide a data type for the parameters. In other words: [code=cplusplus] int … | |
Re: So...have you tried [b]anything[/b] yet? If so, posting a little code would make you look like far less of a "gimme gimme" noob, and someone might actually help you. | |
Re: If a number is divisible by 2, it's even. If it's not divisible by 2, it's odd. You can find out if a number is divisible by 2 by finding the remainder of division by 2. C++ has a remainder operator, %. So it stands to reason that if you … | |
Re: There's plenty of software to control computers remotely, but if you want to do it by phone line, the computer has to be connected to one (which is quickly becoming a scarce occurrence). Most likely you're searching for the wrong thing (because your search strings are incorrect), or you're searching … | |
Re: >For example if i convert 255 from base 10 to base 2 >i am getting 11111110 instead of 11111111. That particular example works fine for me. Though your code has some...interesting aspects. | |
Re: >But the easiest to code is standard qsort() method. Which, despite the name, isn't required to be quicksort. ;) | |
Re: >I'm using the stack twice and I didn't find it efficient. Are you just eyeballing it and thinking "that can't be efficient", or did you profile multiple executions and get hard numbers that proved it's consistently slower than your allowable limit? | |
Re: >after the 10 guesses or if the the guesser gets it correct it >should ask if the player wants to play again and react accordingly. So wrap the whole thing in another loop and prompt for whether the user wants to play again. | |
Re: >it wont compile and I dont understand the error message And we're supposed to divine what that error message is? Maybe you should post it. | |
Re: >out<<num.a; >out<<num.b; First I'd suggest you separate those two values with something. Your actual output is 43,0. [code=cplusplus] if(i==1) { num.a = line[i]; } [/code] At position 1 in "7+i3" is '+'. So the first problem is that you're assigning the wrong character. The second problem is that you're assigning … | |
Re: >can anyone please tell me how? Use stringstream to handle the conversion for you. This relies on the existing formatted input code and saves you the trouble of writing the tricky algorithms yourself: [code=cplusplus] #include <iostream> #include <sstream> #include <string> int main() { std::string line; std::cout<<"Enter a number: "; if … |
The End.