2,827 Posted Topics
Re: [QUOTE=jimJohnson;1212078]I am doing a homework assignment for CSI 330 and not sure how to begin this program. It is asking me to initialize and unsigned int variable mask, with a value whose binary representation has a 1 followed by all 0's. The second part says... For a counter running from … | |
Re: Post it as a link or an attachments rather than the code in the post, I'd say. That way anyone who wants to try it on their own before looking at yours can do so. I have one that I created a year and a half ago. But I think … | |
Re: [QUOTE=nola_Coder;1210006]I want to implement a countdown timer in a game, but need some help figuring out how to do it properly. I know that this is probably a very regular question that has been asked a thousand times, but I've been trying out some methods I found through searching, but … | |
Re: Use code tags and formatting. [noparse] [code] // code here [/code] [/noparse] [code] #include <iostream> #include <fstream> using namespace std; void ReadList(int Array[ ], int N) { N = 0; ifstream input("file.txt"); Array [ return; } void Avgs (int Array[], int N, int& Ave, int& aveP, int& AveN) { return; … | |
Re: [QUOTE=Chrisjj;1200557] infraction noun, formal [COLOR="Red"]the breaking of a[/COLOR] law, [COLOR="Red"]rule[/COLOR], etc; [COLOR="red"]violation[/COLOR].[/QUOTE] Seems like the word matches the definition to me. What's your point? ![]() | |
Re: [QUOTE=Lukezzz;1209656]Hi, I have a question about when you have compliled a Form application as a release where the product exists of: - exe.file - Program Debug Database - Incremental Linker File What I now wonder is that I have in my project some important usernames and passwords. My question is … | |
Re: I don't see the clearing of cin in your code. Here's a full program using Narue's code. Upon failure, you need to clear it and throw away the bad characters. [code] #include <iostream> using namespace std; int main () { int number = 0; // anything but -1. while (number … | |
Re: [QUOTE=RayRay1;1206957]I think that I have too much extra in this code. I'm trying to figure out a way to eliminate some of the functions that I might not need. Basically what I need to do is implement a polynomial that has rational coefficients. I have created two separate codes; one … | |
Re: You only need one thread. [url]http://www.daniweb.com/forums/thread280261.html[/url] | |
Re: [QUOTE=tennis;1206972]Yes, there are different ways to write the program, I am just testing this version of code. I am not asking for alternatives. What I don't understand is why there is a run-time error if I omit the following 2 lines, x=new int; y=new int; Also why I get a … | |
Re: Here is your code, formatted. It's much easier to read. Perhaps you are mixing spaces and tabs? Don't. It will look terrible on Daniweb if you do. [code] #include <iostream> #include <fstream> // Header to use input and output #include <string> using namespace std; void main() { ifstream ifile; // … | |
Re: [code] while (inFile){ for (n = 0; n < 7; n++){ inFile >> truckWeight; } [/code] You're losing all your data here. You read in about 100 numbers and overwrite the last number each time. Seems to me that truckWeight should be a two dimensional array since you have a … | |
Re: A few options for 2-dimensional arrays. [LIST=1] [*]Static allocation. [*]Dynamic allocation. [/LIST] Static allocation is when you know the size of the array beforehand, as you do. You know in advance that the matrix will be a 5 x 5 matrix. So you are in the first category (static). That's … | |
Re: You need to track down where your error occurs. It can be in one or more of at least three places: [LIST=1] [*]Bad parameters passed to the constructor on line 196. Display the parameters before the call. If they are incorrect, debug prior to line 196. [*]Good parameters passed to … | |
Re: Is the class named Rational or is the class named RationalNumber or are there two classes? If there is no class called Rational and you have anything that looks like [ICODE]Rational::[/ICODE], the compiler/linker has no idea that it is supposed to be a class and will thus try to find … | |
Re: Without seeing the driver program it's hard to tell, but the design seems flawed. These functions shouldn't take the char[] parameter since they are member functions. Your char[] array is thus passed with the object, so you don't need it as a parameter. Thus I would imagine you would want … | |
Re: Everything you posted looks portable from Windows to Linux and vice-versa, so I would imagine the problem would be elsewhere, either in code you haven't posted or some linking or compiler or makefile issues. I'd try building it with g++ on Windows outside of the IDE using whatever Makefile you … | |
Re: Break it into pieces and you'll quickly find the exact offending line: [code] infile >> employee[ idx].id; infile >> employee[ idx].name; infile >> employee[idx].pay_rate; infile >> employee[idx].dependants; infile >> employee[idx].pt; // this line [/code] You'll need to write a >> operator for your PayType enum. What is the appropriate input … | |
Re: [QUOTE=i_luv_c++;1205354]hey guys im new to recursion to recursion..pls look at the function call ...question is how do i call in two functions at the same time..and which one should i return thank you. [/quote] This code cannot return false. You need at least one line that says "return true" and … | |
Re: calcIns is a FUNCTION, not a VALUE in your program. You have no variable called calcIns. I assume you want to display the results of a CALL to the function, not the function itself. In that case, you need to call calcIns and assign a variable to equal the return … | |
Re: We can't help you as you have not provided file list_reversal.cpp. You need to make an attempt and post here with a specific question when you get stumped. You've simply copied and pasted the assignment verbatim. That's going to get you no help. Give it a shot first and post … | |
Re: The whole beauty of vectors is that you don't have to handle any of the memory management. All the sizing and resizing is done for you when you add and remove elements. Thus they are PERFECT for unknown sizes. I'm sure there's a bunch of malloc, calloc, and realloc calls, … | |
Re: Visual C++ Format option to the rescue, plus changing all tabs to 4 spaces. On Daniweb, a tab is 8 spaces, so if you mix tabs and spaces it looks terrible. [code] // DelgadoMarcoA1.cpp // Written by Marco Delgado // Data finished: May 6th 2010 // Program description: #include <iostream> … | |
Re: First thing that you need to do is write a driver program that has a main function in order to test it. Test the constructors and printRational. If you haven't written printRational, write it because you'll need it a lot when testing. [code] // driver program // includes int main … | |
Re: [QUOTE=john10;1200552]Thanks for this, didn't notice the post till after I completed my result. I'll try it out thanks. Edit: I tried it, problem with it is that it displays the canvas twice, i think it's preferred to be just displayed once.[/QUOTE] So this is a sine-wave plotted against time? Since … | |
Re: This isn't a code snippet. It's a regular thread. [code] getData(dataFile, data[], count); [/code] Function calls shouldn't have the [] in them. Function prototypes do, but not function calls. Delete the [] in the function call and try recompiling. | |
Re: Well, I've never heard an American say that Australians say ""You beauty mate", so I won't say you're wrong, I'm just puzzled. Hadn't realized that Aussies stereotyped us as stereotyping them that way. There's nothing different about McDonald's here than anywhere else in the world. I don't think anything's bigger … | |
Re: [QUOTE=hurricane123;1198195]is there any difficulties of sorting parallel arrays?if there then what are those[/QUOTE] Are you still here? You'd think that after being caught in straight-up plagiarism you would have left. [url]http://www.daniweb.com/forums/thread269344.html[/url] Really, don't make it so obvious that you are completely unwilling to put any effort into anything. | |
![]() | Re: [QUOTE=ardav;1150525]Is it me or are there loads of members reanimating long-expired threads? Is there a way to automatically close threads say a certain amount of time after the last post? Being faced with 2 year old posts cluttering up my favourite forum is seriously annoying me. If the posters had … ![]() |
Re: Fix the code tags. Replace all tabs with 4 spaces. Repost, but preview first. Look at the link Walt P posted. [noparse] [code] // code here [/code] [/noparse] Embedded code tags don't work. Preview before posting! | |
Re: Write a program that opens and closes one of the files that isn't working and does nothing else. See if that works. If THAT works and the full program doesn't, compare the code. If the code is the same, then make sure you aren't: [LIST=1] [*]Deleting the file mid-program. [*]Opening … | |
You see an orange or green dot and are curious. Who gave it and why? Currently you can't find out without giving some rep yourself. I propose a "Cancel" button after you view the rep. Sometimes you don't want to weigh in. You just want to view the comments. | |
Re: Close on the code tags. You forgot an opening bracket. [noparse] [code] // code here [/code] [/noparse] What error messages do you get, and what are the corresponding line numbers? | |
Re: [QUOTE=Hidden_mistakes;1194951]I am trying to write a racing game but i need some winning conditions. Im not sure where to start, any pointers would help. Im using Visual C++[/QUOTE] Start by explaining what you mean by "winning conditions" and what exactly the program is supposed to do. | |
Re: Anyone who has ever been around a high school where there has just been a car accident that killed a bunch of high school students there will notice that they are far more stunned by the fact that someone their age can actually die than, say, a bunch of 25-year-olds … | |
Re: I have a few code snippets that might be of interest. I've been meaning to post some more or at least post some diagrams that explain the algorithm a little bit, but I haven't gotten around to it. [url]http://www.daniweb.com/forums/search5523578.html[/url] | |
Re: In addition, consider the overall design. Do you want to use integers as the values of the sides? I would use doubles. Be wary of comparing doubles using the == operator as you do in [ICODE]isRight ()[/ICODE]. There's a potential for round-off error. Since you are typecasting from integers and … | |
Re: As long as it's a reasonable formula. A big (and completely legiimate) beef by teachers at schools in lower socio-economic schools is that they can hardly expect to compete with schools in rich areas performance-wise since they have a whole bunch of problems that the schools in rich areas don't … ![]() | |
Hopefully this is fairly basic. I've never used enumerated types in Java. I'm sort of trying to take my C concept of them and make it work in Java. Basically use them as constant integer values. That might be putting the square C block into the round Java hole. I'm … | |
Re: I am looking for something in the code somewhere along the lines of: [code] if (/* node is found */) { // increment node.frequency }[/code] I see nowhere where[ICODE] frequency[/ICODE] is used at all. Your insertion process should be something like this: [LIST=1] [*]Search the tree for a word. [*]If … | |
Re: [QUOTE=vmirz;1186210]My goal is to implement a sorting into a linked list. I have everything working thus far, but I'm a bit stumped as to how I need to change my insert function in order for an element to be placed in the appropriate location. [/QUOTE] First you have to have … | |
Re: Code tags: [noparse] [code] // put code here [/code] [/noparse] Please edit your post and put the code tags in. It's easier to read. | |
Re: [QUOTE=jephthah;1163914] But I have yet to see [B]any [/B]time anyone [B]ever [/B]contributed anything remotely meaningful to a thread that has been dead for more than three months. [/QUOTE] [URL="http://www.daniweb.com/forums/thread90228.html"] Exhibit A[/URL] Some bumps are worth reading. | |
Re: Reposted with code tags: [noparse] [code=JAVA] // code] [/code] or [code] // code] [/code] [/noparse] [code] 3 Sample output * *** ***** *** * [/code] [code=JAVA] public class p2.java{ public static void main (String args[]){ int x; SimpleInput sInp = new SimpleInput(); x = sInp.getInt("please enter an Integer"); int y … | |
Re: Lines 43 and 44 don't make sense: [code] if(root == NULL) root[i][j] = new node(a); [/code] This would make more sense: [code] if(root != NULL) root[i][j] = new node(a); [/code] The whole point of checking for NULL is so that you don't dereference a NULL pointer. You're checking to make … | |
Re: [QUOTE=timbomo;1176408] //function that rolls dice. IT DOESNT ROLL I GUESS YOU CAN SAY. I WAS THINKING OF PUTTING THIS IN A SWITCH STATEMENT BUT HAVING PROBLEMS WITH GENERATING RANDOM NUMBER [CODE]int if_roll() { int which_Num; unsigned seed = time(0); srand(seed); which_Num = rand() % 7; return which_Num; }[/CODE] [/quote] You … | |
Re: [QUOTE=pinknblu;1165669]Thank-you, I figured that much....will continue to work on it...later. If anyone else has input..it would be appreciated.[/QUOTE] Code tags. [noparse] [code] // code here [/code] [/noparse] Take the errors one by one. Some are obvious: [code] int line (char *p) [/code] What's this? [code] cin.getline() [/code] Where does the … | |
Re: This is the same issue as your other thread. [url]http://www.daniweb.com/forums/thread270830.html[/url] I explained what the problem was there. You are using uninitialized variables. I suggested back then that you initialize your arrays to something like -999999 so the lack of initialization will stand out. You can't use uninitialized variables in calculations … | |
I have some code that works. However, when I try to make it not work (i.e. try to execute a non-existent program), I don't see any indication that it hasn't worked. Here's the code snippet. [code=C] pid_t pid; // char *const paramList[] = {"/usr/threshold/bin/preconfig.sh", options[indexSelected].optionName, NULL}; const char* paramList[] = … | |
Re: Yup, you have thirty minutes and that's it, then whatever diatribe, venting, extremely bad coding help, etc., is set in stone for eternity, public for all the world to see. You have thirty minutes, and that assumes no one has REPLIED to your post (hence putting YOUR post in THEIR … |
The End.