2,827 Posted Topics
Re: Here's mine. Haven't tested it with anything but the posted file, but got the right answer. [code] #include <iostream> #include <fstream> #include <vector> using namespace std; struct Triangle { int peakVal, triangleVal; }; void usage() { cout << "Usage : ./Triangles filename"; } int max(int num1, int num2) { if … ![]() | |
Re: [QUOTE=avarionist;]4 characters are numbers that represent North south east and west respectively the other 4 characters are delimiters(i don't know why i put them in maybe for easier reading?)[/QUOTE] No, it makes for more difficult reading. If the file format is one that you created yourself, you are better off … | |
Re: As a side route venture back onto the original rule-breaking, which would have been the actual topic had the posts not been so ridiculous, what exactly is a "fake" signature and why is it a problem/against the rules? I gather that it is an e-mail address WITHIN an actual post … | |
Re: [QUOTE=rroky;593933]Please any one can help at this problem I have with javac. I have download the java jdk1.5.0_15 at least 20 times in three (3) machins and it do not compile. Actualy it can not read the file. Javac is installed and is on bin, when I type javac it … | |
Re: Maybe when you see a line like this: [code=C++] cout << "*"; [/code] replace it with this? [code=C++] cout << MyCharacter; [/code] | |
Re: You don't need to zero out the array. You already know the size (5 x 3), so declare it that size: [code] int matrix[5][3]; [/code] i would just read it in like this: [code] for (int i = 0; i < 5; i++) { for (j = 0; j < … | |
Re: Line 8 makes line 7 pointless. You're overwriting what you just assigned, aren't you. | |
Re: Define "bad pointer". This line is fine and will give you a perfectly good pointer to an array of 16 pointers to characters. [code] unsigned char** intext=new unsigned char* [16]; [/code] Note that it allocates absolutely no characters. So unless you something else between the line above and this line: … | |
Re: [QUOTE=spartan118] Also, I've attached the two main files of my program. [/QUOTE] Why do you have two main functions? That's going to screw everything up. Besides that, make sure you have #ifndef guards in your header files. If you try to define something twice, it screws the linkage up, so … | |
Re: [QUOTE=esdel;1249168]Sorry folks but after 30 minutes this is the ONLY place I can find to ask a question. It is a VERY elementary question! Can you please explain to me about "who I am" as regards emails and how other people regard me? For example I have emailed using SNIP, … | |
Re: Code tags and formatting please. All your errors appear to be due to the fact that you refer to a ThreadPanel class, but you do not provide one so it doesn't know what to do when it sees the word ThreadPanel in your code. | |
Re: Your check function only returns -1 no matter what. Is that what you want? | |
Re: [QUOTE=hatzi8;1244336]Hi, i've have just created my first program in visual c++ 2008 express edition and i'd like to know, if I can create an exe file to make this program run independently from visual studio. thanks[/QUOTE] Absolutely. Once the .exe file is created, the program no longer needs Visual Studio. … | |
Re: [QUOTE=bree9482]Hi guys hope ur are all well! I have a program im trying to finish and its not going well. I am quite new to C++ and am not the greatest. I have code that ill post, but the problem is when i run the program with the readfile(); function … | |
Re: [code] std::ifstream stm; stm.open("str100"); double d; stm >> d; [/code] If you have a file called "str100" with a double in it, this is how you could read that double into the variable d. You had it fine except for the second line. I'm not sure what you were trying … | |
Re: [QUOTE=cscgal]That's why you should use both. :-P When you use DaniWeb's built-in mechanism, the ad server is never contacted. The added bonus is that things on the site are more streamlined, such as the right area of the first post in a thread going away and the problem that you … ![]() | |
Re: This is a math problem, first and foremost, more than a computer science problem. As you correctly mentioned, you don't want to calculate n^n. Even if you could use BigInteger (and you may be able to), I imagine that misses the point of the math problem, which is that you … | |
Re: > How can I use code tags that do not produce line numbers? I used to use quote tags, but that is just almost unusable now since the quoted text is hidden. So to preserve the spacing I use code tags, but I don't like the line numbers. > > … ![]() | |
Re: I don't see the word "new" or the word "malloc" or the word "calloc" anywhere in your code, so it doesn't look like you are creating a new array anywhere that won't go out of scope once it leaves the function. That's one problem, even if you had set the … | |
Re: [QUOTE=debugger09;1234631]thanx for the reply [B]daviddoria[/B] will it work on DEV C++ ?? i think the program runs only on linux platform i not able to understand the code :(([/QUOTE] It's Boost, so you have to download/install it and play around with it. It's not part of the C++ standard, but … | |
Re: [QUOTE=drt_t1gg3r]All of the data is copied except the container data.[/QUOTE] What do you mean by the "container data"? [QUOTE=drt_t1gg3r] Now all of the Gets/Sets are appropriate to the data members. one returns a copy of the value, and one sets the value to an amount of the correct type.[/QUOTE] Normally … | |
Re: You want to use String.split. Use white space as the delimiter. That'll split your big String into three smaller Strings. Then you can use parseInt. [url]http://java.sun.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String,%20int%29[/url] Lots of good samples out there. Google "Java string split example". | |
Re: Lots of problems before even touching the polymorphism part. Read the compiler errors. Some will tell you exactly what the problem is. Some are more cryptic. [LIST=1] [*]Any non-void function should have a return statement. [*]Function calls should not have the type in it (i.e. leave "char" out of the … | |
Re: [QUOTE=cscgal] The idea behind this is that if you're just directly quoting another post, it gets hidden by default, because it adds no new value to your post.[/QUOTE] It does add new value to your post and possibly their post because it can emphasize a particular point that you are … | |
Re: [QUOTE=carrythe1;1230375]thanks - i'm familiar with SWITCH but isn't this just a way of simplifying many IF statements? I still don't know how i would, for example, get the program to use the following logic: <run code and get to input decision point> <pause main program and wait for input> if … | |
Re: [QUOTE=cscgal] Because I don't want to have to scroll past 50 lines of something that I just finished reading every single time someone uses the "Post Reply" button and quotes the previous post ... Hence hiding is the default when using the Post Reply button. then that actually is more … ![]() | |
Re: [QUOTE=drt_t1gg3r;1228041]Well I did a work around. Instead of having the (2) functions in the PERSON class, I put them in each of the PLAYER, COP, and ENEMY classes and everything linked fine. I wonder if it's a Dev-C++ IDE thing. I can't understand why I can't have the (2) functions … | |
Re: [QUOTE=unity;687610]hi i want some good question c/c++ for practice can anyone suggest me some website or any good book[/QUOTE] See the sticky at the top of the C++ forum for both books and practice problems: [url]http://www.daniweb.com/forums/thread67837.html[/url] [url]http://www.daniweb.com/forums/thread70096.html[/url] | |
Re: [QUOTE=The Dude;1189292]Well i understand your point but IT IS A WAY TO BRING NEW MEMBERS ASHORE :) It shouldnt be as obtrusive though and maybe Dani could look into it :) Nice to see you posting BTW :)[/QUOTE] You're missing the point. He has one post and probably never even … | |
Re: You could typecast your return type to explicitly return an int**, which would make it compile, but it still wouldn't run right. I'm guessing that you int** does not dereference correctly from a 2-D array to a 1-D array. arr2d may know it's a 2-d array and thus **arr2d and … | |
Re: [QUOTE=Leppie]didn't like the "mr = mr + temp" and thought there might have been a better way to do this?)[/QUOTE] [code] mr += temp; // equivalent to your code above[/code] [code] mr = mr + temp; //adds 1 to male population fr = fr + temp; //adds 1 to female … | |
Re: I rely on the big orange negative rep flags and the negative votes to alert me to people I should be wary of helping. That and the avatars zone me in pretty fast. All three seem to be missing now. You have to click on the thread now and then … | |
Re: The whole thing is screwy in my opinion. There's tons of people who work very hard for little money who don't get tips. Does the guy cooking the burgers at Burger King work less hard than the guy cooking your meal at a 5-Star restaurant? Does the guy who wipes … | |
Re: [QUOTE=jimJohnson] There is a chance I have no idea what I am doing so just thought that I could just at least start with something[/QUOTE] Compile it and find out for sure whether you have any idea of what you are doing. Report the errors in your post. Does it … ![]() | |
Re: [QUOTE=jimJohnson;1221753]I am working on another linked list problem...really been struggling with this chapter dealing with lists...Here is the instruction for this example... Write an algorithm to search a linked list with the first node pointed to by first for a given item and, if the item is found, return a … | |
Re: [QUOTE=ardav;1159739] I quite fancy the female native - I'm not sure if I'm supposed to.[/QUOTE] You're supposed to. Trust me, you aren't the only one. | |
Re: [QUOTE=Martje;1220452]I am trying to make a list of array pointers, Is there a way that after declaring an array i can adjust the size? For example at start i create a array called : "list[2]" Is there a way that later on i can change "list[2]" and make it "list[3]" … | |
Re: I have a few code snippets that may or may not be of use. I'm not entirely sure what your goal is: [url]http://www.daniweb.com/code/snippet217346.html[/url] [url]http://www.daniweb.com/code/snippet217217.html[/url] I don't know what a trap or a dungeon crawl is. I also don't know what 0 or 1 represents in this array. Is this some … | |
Re: If you have a void function and you want to "return" (i.e. don't execute the code after that line), I'd say your best bet is to break it into two lines: [code] PrimeFactorize(number / 2, factors); return; [/code] That gives you the same "short-circuit" options that a regular "return" gives … | |
Re: [QUOTE=sneekula;614747]I find the amount of people I meet that simply won't vote for Obama because he is half black alarming. There are also many people that have read the republican smear-mail and believe he is a muslim. Bigotry is live and well in this country![/QUOTE] Does anyone have any idea … | |
Re: [QUOTE=jimJohnson;1218024] [CODE] standardDeviation = sqrt (((pow(totalScores, 2.0)) - ((1.0/count) * (pow(totalScores,2.0)))) / (count - 1.0)); [/CODE][/QUOTE] Look at the formula. See if it's correct. If you don't understand the standard deviation formula, stop and do a few by hand. Whenever a compound formula goes wrong, you need to split the … | |
Re: I don't know what the rest of your program looks like, but consider and run this program: [code] #include <iostream> #include <cstdio> using namespace std; class matrix { public: int a; matrix (); matrix (int a); matrix (const matrix & m1); ~matrix (); matrix b (matrix c); matrix operator + … | |
Re: Pick whatever sort you want to use to sort integers (you have chosen merge sort). Presumably you have this data stored in a struct/class and you have an array of this type. Your ==, < and > comparison operators for this struct/class will be based on this first element. You'll … | |
Re: [code] ifstream[COLOR="Red"].[/COLOR]charge("shippingcharges.txt"); [/code] Replace the dot with a space. [code] ifstream charge("shippingcharges.txt"); [/code] | |
Re: When reading an integer with scanf or fscanf, you need to provide it with the address of an integer. You have NEW defined as an array of size 1 (why not just a plain old single object?), so you want to dereference it, then specify which data member, then give … | |
Re: Use code tags. [noparse] [code] // code here [/code] [/noparse] What's the question? One thing that jumps out is that you are passing variables by value to a void function, changing those variables inside the function, then exiting the function, which does nothing. You need to either pass by reference … | |
Re: I suggest approaching the problem in the following organized manner. You want to see where it first breaks. Thus if the error shows up in, say the Search routine, that may not mean the Search routine is incorrect. It may mean that the Insertion routine is incorrect. Presumably you have … | |
Re: [QUOTE=Rob E;1213343]Thank you for helping. The "//" came over by mistake. My biggest mistake is(please forgive my ignorance) I don't fully understand your answer. I thought including the [I]math.h[/I] would let us use the power function. I'm reworking the program and re-reading the chapter. I'll post it again after some … | |
Re: Your swap is incorrect. Swapping is done like this: [code] // Suppose x = 4 and y = 6 and x and y are to be swapped int temp = x; x = y; y = temp; [/code] At the end of the swap, x will equal 6 and y … | |
Re: You need code tags, formatting, and a more precise question: Best fit, worst fit? Best fit and worst fit of what? What exactly is the problem? Here's your code with code tags and formatting. It's much easier to read, though it looks better in an IDE than on here. [code=JAVA] … |
The End.