2,827 Posted Topics
Re: You're going to need either a new array to represent the combined values or you need to use the old array and delete some elements. You're sending data to the file too early. What if there are THREE records with the same date, not TWO. Assuming you don't need to … | |
![]() | Re: You should verify that you are indeed in an infinite loop and find out where exactly. Make sure it's not a program crash or something. Putting some println statements in the loops should do the job. If they print forever, you're in an infinite loop. Line 79 is going to … ![]() |
Re: >> I'd like not to use the Collection.sort as I've tried for a while, and I think it's beyond my abilities... Anyone have any ideas? Even if it's just psuedo or anything, doesn't have to be actual code. if you don't want to use the "sort" function, don't, but you'll … | |
Re: Nothing in the code keeps track of how much REAL data you actually have. You have records of real data, so this will display 4 records of real data, then 6 records of garbage. You'll want to set up a new variables and change the code so that it flags … | |
Re: >> I dont even know where to start. Start by writing a main function that asks the user for input, the passes that value to the function and have the function just return that value. Then print it out in main. After that works, start writing the real function. Before … | |
Re: [QUOTE=Mayank23;]how can i use a string in a switch statement?[/QUOTE] You can't. You can only switch on "integral types" like char and int. You need to do a bunch of if-else if statements for strings. | |
Re: One (system("pause")) involves asking the operating to run a system command and spawn a new process and the other simply waits for input to your program. They are about as different as night and day. As to which to use, cin.get() is usually preferred. If you do a quick Daniweb … | |
Re: The way you have it set up, I imagine it is THIS: [code] public void setLab(Grade g, int index) [/code] Otherwise how do you know WHICH grade to set. Setters and Getters don't do much. They are usually one line functions. The key is the "public" versus "private" modifier. grades[] … | |
Re: This is an error: [code] int i = 0; String bogus[i]= ""; [/code] Perhaps you wanted this? [code] int i = 0; String bogus[] = new String[10] bogus[i]= ""; [/code] This line would be an error no matter where you put it: [code] String bogus[i] = ""; [/code] | |
Re: >> I know how to do palidnromes with strings, but don't know if there is an easier way with integers Then covert to a string and do the palindrome check. I don't see a [ICODE]bool IsPalindrome(int)[/ICODE] function anywhere. Don't you need one? One way or another, you need to isolate … | |
Re: I've never heard of Roman Decimal Numbers either and I'm trying to picture how you would differentiate 1.1 from 1.01 without a zero. I would confirm they exist and write out several examples on paper before attacking the C++ angle of it. [EDIT] Never mind. I had a terminology problem. … | |
Re: >>i give him to him by a download link, its a .exe file then he double clicks on it and runs it, but then the program just goes away quickly. But what kind of program is it? If it's a console program, once the program exits, with or without an … | |
Re: Two possibilities: [LIST=1] [*]Garbage in, garbage out -- The calculation code is not getting the input you think it is, so it's giving bad results. [*][*]Good data in, garbage data. The data being delivered to the calculation code is valid, so the calculation code is wrong. [/LIST] Figure out which … | |
Re: Not pertaining to your question, but important enough to point out... You should move line 35 up to the top of main. It needs to be executed once and exactly once. Sticking it in the while loop as you do makes numbers less random, not more random. As to your … | |
Re: Here's a decent iomanip tutorial: [url]http://www.cprogramming.com/tutorial/iomanip.html[/url] If you scroll about halfway down, you'll see an example. For some reason they have the entire webpage as a link so I can't copy and paste the code. Look for "Setting the precision of numerical output with setprecision". There are some examples on … | |
OK, here's what I want to do (I realize the code below doesn't work, but it's what I would LIKE to do). I've converting things from C++ [code=JAVA] public void ChangePrimitiveArray(byte bytes[]) { bytes[0] = 1; } public void foo() { byte bytes[] = new byte[2]; bytes[0] = 4; ChangePrimitiveArray(bytes); … | |
Re: In addition to the post above, line 80 is confusing. [code] cout << main(); [/code] I suppose it might work to call main() from your program (but it's not a good idea. There are better solutions), but what are you trying to do with the "cout" part of that line? | |
Re: >> i have no idea please help :( Ancient Dragon's right. Try it yourself first. #2 and #3 should not have been posted. All you had to do was compile and run them and you'd know the answers. #1 is less obvious. Now what precisely is your question? You need … | |
Re: You are not telling the compiler what type "canal" is. I am guessing that "canal" is an integer, but you don't specify this: [code] public void sincronizarCanal(canal) [/code] If canal is an integer, you should change it to this: [code] public void sincronizarCanal(int canal) [/code] However, this also won't work … | |
Re: My critique would be the following. The code is difficult to read, at least to me. iCounter, iNumber, iRemOfOriginal, etc., these are all variable names that are not obvious to me so it's hard for me to follow the logic. The task seems fairly straightforward. [LIST=1] [*]Isolate the digits. [*]Manipulate … | |
See title and screenshot. This photo came off an XP computer, was burned to a disk, and I'm attempting to copy it to a Windows 7 computer. I'm logged into an accout with Admin access. It transferred no problem onto an XP computer and transferred no problem from the CD … | |
Re: If any of you are assuming I look exactly like Ryan Reynolds wishes he looked, I have to congratulate you on being 100% correct. | |
Re: [code] for(int i = 0; i [COLOR="Red"]>[/COLOR] NUM_IN_TEAM; i++)[/code] Look at the red sign carefully. Perhaps you mean this? [code] for(int i = 0; i [COLOR="Red"]<[/COLOR] NUM_IN_TEAM; i++)[/code] | |
Re: >> child porn, rape videos These only get a 6 month ban? | |
Re: This isn't encryption. No private keys are needed at all. Toss them out. All you're doing is XORing things, which means the next XOR with the exact same public key "decrypts" the message: [code] #include <iostream> using namespace std; /*********************************************************** XOR Process for both encryption/decryption processing ***********************************************************/ string XOR_Encryption(string toBeEncrypted, … | |
Re: [QUOTE=Ahna;] A friend of mine recently compiled a simple program to roll dice. He explained he can successfully compile it and even make it run in the compiler, but he does not know how to get the game to play as an executable file/or doesn't know how to export it … | |
Re: Seems like part math problem, part computer science problem. You could brute force it, I suppose (i.e. don't solve it mathematically by deriving an equation ahead of time), or you could figure it out mathematically based on a, b, c, and d, stick some formula involving a, b, c, and … | |
Re: >> also I dont fully see where these would fit in the real world can anyone give me some example? Faster calculation, storing boolean variables in a single bit. Too many to mention. Asa personal example, I'm currently working with a wireless protocol. Memory and bandwidth are extremely tight, so … | |
Re: The easiest sort to write is the bubble sort: [url]http://en.wikipedia.org/wiki/Bubble_sort[/url] >> I have [COLOR="Red"]3 ints[/COLOR](int1,int2,int3), each spanning from 5 to 17, now i want to compare int1 and int2 and type out all numbers from lowest to highest([COLOR="red"]5,6,7,8[/COLOR]...), than i want to compare also int2 and int3 and type out … | |
Re: [QUOTE=alexchen;]Line 107-110 [CODE]switch(toupper(ch)) { case 'J':// break; case 'N': // break; default: cout << "Write J/N"<<endl; }[/CODE][/QUOTE] alexchen, I know you're trying to help, but please stop and think. This block was perfectly fine before. [code] ch = toupper(ch); if (ch == 'J') restart = true; if (ch == 'N') … | |
Re: So what's the question? It looks like a copy and paste of your homework assignment. | |
Re: Stringstreams might be your best bet here. [code] #include <iostream> #include <sstream> using namespace std; int main () { string bigString, stringAfterNumber; int number; bigString = "25 from a car accident"; stringstream ss (bigString, stringstream::in | stringstream::out); ss >> number; getline(ss, stringAfterNumber); cout << number << stringAfterNumber << endl; cin.get(); … | |
Re: void wczytaj(void) { std::ifstream infile("input.txt"); input1 a; int i, j; std::vector<input2> b(2); input2 c; string temp; char byleco; double d = 0.0; while(infile) { infile >> a.model; infile >> a.steps; infile >> a.timehorizon; infile >> a.S; infile >> a.u; infile >> a.d; infile >> a.r; infile >> a.noiip; infile.ignore(); for(int … | |
Re: >> The best way is to get the original coder to explain it to you. If the code is well written/documented, the coder has already written and documented it so that it can be understood. If you have to ask them, to my mind, that means it wasn't written well … | |
Re: >> Declare an integer array of size 10. Only first ten armstrong numbers can be stored in 0-9 indexes of your array , means Initially you have to find out first ten arm strong numbers and then store it in your array Fairly straight-forward. [LIST=1] [*]Declare an integer array of … | |
Re: >>I still don't know what to do. You need to write this function: [code] void showMenu() [/code] or you need to remove all traces of it from your program. | |
Re: >> still having problem by reading your thread What problems? Post a code snippet. | |
Re: [QUOTE=gregorynoob;706728]it's about having a board with 9 numbers, 1-9 obviously. they are organized in a 3*3 matrix. the solved problem looks like: 123 456 789 the problem is, you are given a scrambled matrix, and you have to fix it using 4 possible moves, rotate top left 2*2, top right, … | |
Re: >>how can i merge the values of the arrays? Merge how? Do you want to take 10 values from the first file and twenty values from the second text file and end up with an array of 30 values where the 20 values of 2.txt are appended to the ten … | |
Re: Commas won't work here. You want &&. [code] if(actid != 1 && actid != 2 && actid != 3) { cout << "you must enter an integer"; return 0; }[/code] Checks for 1, 2, 3. Add to it for the other digits. | |
Re: Code tags won't help this mess. If you're going to do a verbatim copy/paste, you need to at least make sure you copy and paste something legible. Get rid of all the | characters, etc. Why is this a poll? No, what you posted makes no sense. On the other … | |
Re: >> As you may have guessed, I’m not all that concerned with third parties, even advertisers, knowing the age, gender, UDID, and/or the general (or even specific) location of my device’s end-user (that’s me). To worry about such a thing just seems silly. Count me out. If I didn't give … | |
Re: Can't help much with the code. It looks Microsoft-specific? But I don't see where you're creating separate processes. I see Reader and Writer objects being created, but no separate Reader and Writer processes? Maybe I'm missing something. I'm a little confused as to what you want to do with this … | |
Re: I can't read this code. The indentation is all messed up. You should format it. You should also stick some brackets in to make it crystal clear what's inside the for-loop starting on line 27. >> it always making some error report. What's the error message? You should provide it. … | |
Re: Seems like deja vu. I thought this problem was already fixed. [url]http://www.daniweb.com/forums/thread333415-2.html[/url] Line 56 - Even if index is properly calculated, what is the purpose of this while loop? | |
Re: I disagree. Questioners need accurate answers, particularly beginners. This forum and all the others are flooded with inaccurate answers that often never get corrected with the proper advice. Hence when you do a google search on a topic you don't know, you often have to wade through several pages of … ![]() | |
Re: The formatting makes the code almost impossible to read, at least for me. Line 54 - Are you intentionally using commas or are those supposed to be semicolons? Could be OK, but looks a bit suspicious. I'm more than a bit rusty on commas and comma operators, if I ever … | |
I have a project with a bunch of different options that you can turn on and off sprinkled throughout many files. You comment and uncomment the options you want, much like the php.ini file in PHP file, though this is actual code. It looks something like this: [code] //#ifndef _OPTION_1 … | |
Re: [QUOTE=samaitaben;632374]Can any one please assist with code for two objects coming from different direction. Subsequently, collide after intersection. The objects should be moving at 80km/h. And collision should happen shortly 30 minutes after take off[/QUOTE] That's a program with many parts. You need to provide much more information. Is this … | |
Re: If you are trying to implement arkoenig's method, as I understand it, since you have 12 numbers, you would want to make sure you generate random index(es) exactly 12 minus 1 = 11 times. That means you should be calling rand() from inside a loop. Make sure your code does … |
The End.