2,827 Posted Topics

Member Avatar for jonnyboy12

I know of no "out word" in C or C++. I don't know if that is pseudocode, but if it isn't, it's a syntax error in either language. If "out" refers to "cout" or "output" or "standard out", well, I'm not going to try to guess what you mean. Please …

Member Avatar for Ketsuekiame
0
168
Member Avatar for fishsticks1907

Line 155 isn't going to catch the problem. Try changing line 155... [code] if(!cin.good()) //here [/code] Your cin stream is corrupted when the user enters a non-digit. You need to clear the stream, output an error message, then let the user try again. The problem isn't thht the user entered …

Member Avatar for fishsticks1907
0
267
Member Avatar for Philip435

When a recursive function works for n, but not n + 1, chances are it's one of these 3... 1. Mathematically there's a whole in the logic. Probably not the case here. 2. You've run out of stack space. Probably not the case here. 3. You've exceeded the bounds of …

Member Avatar for VernonDozier
0
83
Member Avatar for evanovan

>> p.s : i use strcmp to find the specific location for the node . There's your problem. You are going to have to write your own comparison function. strcmp has its own idea of what the order is. If you have a different idea of what the order is …

Member Avatar for evanovan
0
204
Member Avatar for megaman656

Yes, it's possible. It would be something like this... [code] int multiplier = /* multiply by 10, 100, 1000, whatever based on the number of digits in b */ int combine = (multiplier * a) + b; [/code] Your job is to figure out how many digits b has. There …

Member Avatar for VernonDozier
0
106
Member Avatar for ineedsomehelp:3

You have segmentation faults all over the place. That may or may not be your problem, but fix them, then try again. For example, ang[] has length 4, so valid indexes are 0 through 3. Line 12 uses an index of 4. Unless that's on purpose, change it. Ditto line …

Member Avatar for ineedsomehelp:3
0
332
Member Avatar for Vladnaka

>> I am using Visual Studio 2010 if that matters. I don't think it matters. This is a C++ issue. If you try to read "z" into an int, cin just keeps trying and it will never get that int. You need to reset it to a good state and …

Member Avatar for Vladnaka
0
475
Member Avatar for chuyauchi

I see a few good candidates for functions here. A function generally tries to do one and only one thing. That's a general rule with plenty of exceptions. One thing that can be placed into a function is the welcome message. That's short enough that it might be worth combining …

Member Avatar for WaltP
0
120
Member Avatar for rithish

[QUOTE=rithish;1767993]what is the use of malloc,calloc,realloc ?? i studied i didnt get proper knowledge .why instead of this why cant we use array???[/QUOTE] I can't explain malloc, calloc, and realloc better than all of the tutorials. cplusplus.com is my go-to site. [url]http://www.cplusplus.com/reference/clibrary/cstdlib/malloc/[/url] As to why you can't use an array, …

Member Avatar for deceptikon
0
122
Member Avatar for Snow_Fox

newWord has length 0, so that's a seg fault. [code] newWord[x++] [/code] Try appending a character using the += operator instead. [url]http://www.cplusplus.com/reference/string/string/operator+=/[/url]

Member Avatar for Snow_Fox
0
1K
Member Avatar for stevo7624

An issue that is not part of your question: what about ties? Also, this is a boolean function. It should return true or false. [CODE]return cout << "Player 1 Wins!" << endl << endl[/CODE] doesn't make sense. As to your question, either make an Ace's rank equal to 14 or …

Member Avatar for stevo7624
0
128
Member Avatar for whitech

Lines 17 and 19. "7" is an illegal index. You want the beginning of the string, not the end anyway, so use 0, not 7 as the second array index in lines 17 and 19. And since it's 0, you can actually drop that second index. [code] scanf("%s", colour[i]); [/code] …

Member Avatar for Subhasis giri
0
122
Member Avatar for DoubleZ

Line 14. "/" is a legitimate C++ operator, not a comment. You'll be treating "8 / 2" as a partial comment. You have at minimum 4 tokens: "//", /*", "*/", "\n". Three of them are multi-character, so your code is going to have to be more complex than reading in …

Member Avatar for Panathinaikos22
0
225
Member Avatar for gourav1

>> in this code, when i give array of 26 or 27 then it doesn't work, but when i give 28 or higher it works properly as i want, why is this so ? although i am using only 26 character array. then why is it working when it's size …

Member Avatar for deceptikon
0
239
Member Avatar for ruval002

Well I suppose you'd pass it all of the arguments except for the first one and it would expect exactly one argument (the directory), and if it got more than one, it would return an error. Or just assume they gave you the right number and pass it a string. …

Member Avatar for ruval002
0
164
Member Avatar for ahu

Repost the formatted code with code tags. Code is unreadable without code tags. [noparse] [code] // code here [/code] [/noparse]

Member Avatar for WaltP
0
2K
Member Avatar for hello2419

[QUOTE=hello2419;1762957]Im wondering would anyone be able to help me with making a scoreboard in c++ for a football game...Any help would be great as i cant find any info on the net.[/QUOTE] Details, details, details. What data needs to be stored? How is the data stored in RAM? Are you …

Member Avatar for VernonDozier
0
807
Member Avatar for johnnyzats

Can't get what to output? No functions are called. You just read in a string and don't attempt to print anything or call any functions and the program ends, so the program should run "fine" as you say, but not really do much. Is the question how to convert a …

Member Avatar for WaltP
0
759
Member Avatar for darshilpatel34

Before tackling your question, you need to get the thing to compile with what you have and follow the spec... [quote] [COLOR="Red"]Double[/COLOR] data field named annualInterestRate that stores the current interest rate. [/quote] Now your code... [code] private: int id; double balance; [COLOR="Red"]double[/COLOR] annualInteresetRate; [/code] So far so good. But …

Member Avatar for VernonDozier
0
181
Member Avatar for shean1488
Member Avatar for faithful4ever

I'm not sure I understand the algorithm. In particular, line 12 appears to have no effect at all. You change the value of a local variable, then don't do anything with it. In line 11, basePos is 1, so you're multiplying by 1. Again, no effect. It seems like you …

Member Avatar for histrungalot
0
742
Member Avatar for swissknife007

Nothing jumps out at me for why it doesn't work. The algorithm isn't an efficient one, but at first glance it seems like it ought to give the desired results. You haven't listed the data set that DID NOT work. Line 44 -- Can mode ever be higher than count? …

Member Avatar for VernonDozier
0
891
Member Avatar for koricha

[code] void MyArray::shift_elements(int index,int pl) { for(int k=0;k<pl;k++) { int temp; for (int i=0; i<(index -1); i++) { temp = storage[index-1]; storage[index-1] = storage[i]; storage[i] = temp; } } }[/code] Any shifting algorithm that requires swapping or a nested loop is inefficient. Do it all in one shot. If you …

Member Avatar for koricha
0
268
Member Avatar for frogboy77

I dislike giving and getting anonymous rep. One should back up one's opinion. Also if you're repping someone, they can't really "improve" whatever it is you want them to improve if they don't know the reasoning behind the criticism. That said, sometimes (OK, often-times) I'll down-vote or upvote someone anonymously …

Member Avatar for zeroliken
0
104
Member Avatar for faintdeath

Delete lines 14 and 15 and see if the program compiles. If it does, then you know there's a problem. Besides, you initialize balance in line 14, then create the object in line 18. I'm seeing a problematic lack of a default constructor for this class. If you care what …

Member Avatar for faintdeath
0
2K
Member Avatar for fredsilvester93

If it returns a "garbage" value, there's a very high probability that it isn't returning anything at all, so check that function to make sure everything returns a value. Stick a debugging statement after line 112... [code] cout << "Uh-oh. Should never get here.\n"; [/code] If that line prints, that …

Member Avatar for VernonDozier
0
101
Member Avatar for ohblahitsme

Okay, then it should be in the same directory as a.out. It gets created on line 82. If it doesn't, line 85 should print. Have lines 89 and 90 print to standard out just to confirm they are executed. Add a cin.get() or two after line 90 to pause the …

Member Avatar for ohblahitsme
0
172
Member Avatar for MasterHacker110

Line 18 doesn't make any sense. Are you sure this program compiles and runs? Line 22 -- why are you appending to the file instead of overwriting? Lines 31 and 33. [code] encrypted += line[i] ^ (int(key)+i); file2<<encrypted;[/code] I imagine "encrypted" is going to end up having all sorts of …

Member Avatar for vmanes
0
188
Member Avatar for stereomatching

It all depends on your demeanor and approach. If you come up to a "senior" as a rookie and have a know-it-all attitude, no one is going to want to hear it, regardless of whether you're 100% correct regarding the code. You haven't made your bones yet. If you're more …

Member Avatar for stereomatching
0
191
Member Avatar for stinkypete

[QUOTE=stinkypete;1746346]Does anyone have an algorithm that generates all 10-digit integers that have at least one digit repeated? Trawling through all 9000000000 of them and checking them individually is too slow. Thanks.[/QUOTE] 10 digit number, 10 digits, none repeated, sounds like you can generate all permutations of 0123456789, then throw out …

Member Avatar for VernonDozier
0
920
Member Avatar for Fixxxer

>> However, chi_squ_end[10000000] bugs me. A lot. Ditto. I'm not sure whether this is complete, but at least the way you have it now, I see no reason to have it as an array. It seems like you can simply substitute a single variable for it. As far as I …

Member Avatar for VernonDozier
0
125
Member Avatar for Dumb Fish

>>AllocatDiff2 = 100 * -0.05; Looks negative to me. Something else must be going on. Post more code and a fuller explanation, particularly the type of AllocatDiff2.

Member Avatar for thines01
0
166
Member Avatar for christian03

[QUOTE=christian03;1748818]please tell me step by step procedure to how to delete the thread that i post ?? please help me guys.[/QUOTE] You can edit a post within thirty minutes and that's it. You can PM the admins, but it's guaranteed that they won't delete since you haven't given a reason. …

Member Avatar for happygeek
0
152
Member Avatar for subith86

To my mind, I can't see any reason to use a string as storage. As you mentioned, in order to use it at all, you have to constantly convert it back and forth. A vector of unsigned ints and a bool for the sign seems better. Just think of it …

Member Avatar for VernonDozier
0
2K
Member Avatar for daldrome

Lines 12 - 19. Having a NESTED loop with strtok as an inner while loop defeats the whole purpose of strtok, particularly the way you have it. Suppose you have three words in the string. For i equals 0, the inner loop from lines 14 to 18 will execute 3 …

Member Avatar for deceptikon
0
2K
Member Avatar for dippatel

Line 31 -- i is generally a loop counter variable. There is no loop (as per your instructions), but there is also no recursion. Why does the "prime" function return a long int rather than a bool, particularly since it can only return a 0 or a 1? Line 47 …

Member Avatar for VernonDozier
0
7K
Member Avatar for gdubz

My guess would be a seg fault. Check your array indexes. In particular, check line 26. Make sure it's what you intend. [code] for(int j = 0;world[i].size();j++) [/code]

Member Avatar for VernonDozier
0
1K
Member Avatar for HelloMe

I've never run into this problem, but Microsoft and Java both have pages dealing with it. [url]http://www.google.com/search?hl=en&source=hp&q=Error+1721.+There+is+a+problem+with+this+Windows+Installer+package.+A+program+required+for+this+install+to+complete+could+not+be+run.+Contact+your+support+or+package+vendor.&btnG=Google+Search&cts=1265877713403&aq=f&aqi=&oq=[/url] [url]http://www.java.com/en/download/help/error_1721.xml[/url] [url]http://support.microsoft.com/kb/891985[/url]

Member Avatar for aliartos
0
722
Member Avatar for bobanderson93

>> the enqueue function works fine. How do you know? Lines 50 and 55. I see the same line in both paths of the if-elese statment, which suggests either one is incorrect or the lines should be removed from the if-statement and placed after it since both paths cause identical …

Member Avatar for Karkalash
0
179
Member Avatar for Azmah

>> Are they allowed to do this? DW always say that they're not allowed to delete a member account. They've said it, but they've never cited a law that states that to my knowledge. I'm guessing it's more along the lines of an agreement they have with whoever pays them …

Member Avatar for Coloradojaguar
0
480
Member Avatar for mrprassad

What were you hoping it would print? If p is located at 0x1000, then "dcis" will be from 0x1000 to 0x1003, then the NULL terminator will be at 0x1004, and p will point to 0x1005, so it will point PAST the character array. "%s" is located at the next available …

Member Avatar for Moschops
0
200
Member Avatar for rfrapp

[url]http://www.cplusplus.com/reference/clibrary/cmath/pow/[/url] There is no pow(int, int) in cmath. You can either write your own or typecast an int to a double and use one of the ones provided by cmath. [quote] double pow ( double base, double exponent ); long double pow ( long double base, long double exponent ); …

Member Avatar for LRRR
0
586
Member Avatar for VernonDozier

Here's the code. Uncomment line 9 and you get the following error. [quote] ISO C++ forbids initialization in array new[/quote] Leave it commented out and it works just fine. I'm not sure why it has a problem with one but not the other. Each object is a 16 byte array. …

0
119
Member Avatar for phorce

>> There are currently no elements inside the vector (If that makes sense?) Makes sense to me. >> You need to resize the vector to M, then [COLOR="Red"]for each[/COLOR] element in [COLOR="Red"]the[/COLOR] vector, you need to resize each element to N, get it? >> Shall I implement [COLOR="Red"]two[/COLOR] for loops …

Member Avatar for VernonDozier
0
2K
Member Avatar for Youg

We can't run it without the input file. The most obvious first debugging technique would be to figure out what the value of TempChar is. Do that by printing it out, but typecast it to an int to make sure it prints. Then look up the value in the Ascii …

Member Avatar for Youg
0
248
Member Avatar for hekri

>> I guess #include <ctime> has something to do with: [B]srand(time(NULL));[/B] but I can't figure out the connection between them. See this link... [url]http://www.cplusplus.com/reference/clibrary/ctime/[/url] Scroll down a little bit and you'll see there is a function called "time". [url]http://www.cplusplus.com/reference/clibrary/ctime/time/[/url] You are using a function called "time" in your program. The …

Member Avatar for hekri
0
3K
Member Avatar for balldrix

Right off the bat, look at lines 45 and 46. Line 45 -- Print i. Line 46 -- Check to see if i is prime. It isn't. Uh oh. How do I un-print? Line 46 -- Calls a non-void return type function and... does absolutely nothing with the return value. …

Member Avatar for balldrix
0
204
Member Avatar for VernonDozier

I have a base class and a derived class. The base class has an int called a that needs to be initialized. I want to create an instance of the derived class, so I call its constructor and pass it an int. I want that to call the base's constructor …

Member Avatar for VernonDozier
0
118
Member Avatar for PrimePackster

[QUOTE=Captain Jake;1731728]OK, we know if we pull out the ranking list, we can see the one with the maximum post, reps or solved threads etc. But this is not about that, its about the people's choice, so who do you think is the best among the big boys here. (Multiple …

Member Avatar for PrimePackster
0
261
Member Avatar for sharpsplit

>> i have almost done it using a series of loops but i cannot seem to get the offset write with the buffer, and it is full of bugs. Sort of hard to debug when you haven't posted it, yes?

Member Avatar for savoie
0
162

The End.