338 Posted Topics

Member Avatar for karthisargunan

It seems as if you have a solution in mind, why don't you try to implement it and if you have any trouble, post your code along with the question. (Something like "I expected it to do ___ but it is doing ___") Oh, and when posting c code, please …

Member Avatar for Ancient Dragon
0
511
Member Avatar for daviddoria

Well...that last example won't work because classes default to private. If you put a public: in front of the int A it would work. However both of the last examples (directly accessing the member or a reference to the member) are violating the principle of data hiding. Anyone using the …

Member Avatar for daviddoria
0
214
Member Avatar for pacx

Do you need to return the whole result in a character buffer? Could you return a vector of strings with one string per trade?

Member Avatar for pacx
0
168
Member Avatar for sonygamer

Ok, comments. Indenting is your friend, feel free to use him consistently. First, why use doubles for the elements of the square. They should all be integer values, right? I don't think I'd use a for(i ... for (j ... to fill the box. I would pre-initialize i and j …

Member Avatar for MosaicFuneral
0
640
Member Avatar for complete
Member Avatar for Murtan
0
156
Member Avatar for daniellamae

When posting c code, please use c code tags [noparse][code=c] /* Your code here */ [/code][/noparse] Yes, that's where the total=0 goes. You could simplify the following code by using else: [code=c] if (ave>91) printf("A"); if (ave>=81 && ave<=90) printf("B"); if (ave>=71 && ave<=80) printf("C"); if (ave>=61 && ave<=70) printf("D"); …

Member Avatar for ajay.krish123
0
293
Member Avatar for Avaviel

Are you sure the link to test1.cpp is the right file? It is calling members of Logbook that are not defined in logbook.h and if I understand correctly, both files were given and you're not supposed to change them.

Member Avatar for Avaviel
0
174
Member Avatar for ashishchoure

It depends more on the specifics of what you're trying to do, but the top options that come to mind are using external programs (like sed or grep) to do the removal or if it is simple enough, you might be able to use [icode]FOR /F[/icode] is your version of …

Member Avatar for Murtan
0
95
Member Avatar for AdRock

If the compiler is complaining, the code is obviously still not right. Maybe you should define the missing symbols? try [icode]int array_words[10];[/icode] right next to where you declare get_content. (They're both used in the same place.) The declaration for [icode]char str[BUFSIZ][/icode] needs to come before the for loop that copies …

Member Avatar for Murtan
0
2K
Member Avatar for adam291086

Your implementation of find_text would only attempt to iterate to lower elements if the current element had no text. Having text does not preclude having child nodes. I rewrote your find_text as follows and I'm seeing output now: [code=Python] def find_text(element): if element.text: yield element.text for subelement in element: for …

Member Avatar for adam291086
0
106
Member Avatar for revenge2

My biggest complaint with Notepad++ is that I can't configure it to use tab characters for C / C++ code and spaces for Python. I've been using the 'PyAlaMode' editor that came with one of the librarys I install (I think it comes with wxPython). It doesn't debug, but it …

Member Avatar for Ene Uran
0
91
Member Avatar for taichou

We are not, nor have we ever been a 'here is your completed assignment because you asked for it' source of information. Our basic premise is to help you fill the 'gaps' in your knowledge. We help you to solve your own problems. Post some code for how you think …

Member Avatar for ajay.krish123
0
90
Member Avatar for homeryansta

To help me and you think about it, write down in english what you think the compare function should be doing. It will help me to understand what you intended and whether or not it will accomplish your goal, along with whether or not the function is doing what you …

Member Avatar for homeryansta
0
208
Member Avatar for raghavendra83

Off the top of my head, I suspect that the fscanf is reading too many or not enough bytes. I recommend that you either treat the whole file as binary or treat the whole file as ASCII. Where you do [ICODE]fprintf(fp, "%d\n", i)[/ICODE] and [ICODE]fscanf(fp, "%d", &i)[/ICODE] you could just …

Member Avatar for Murtan
0
2K
Member Avatar for noureenjee

The code was really hard to read... When posting c++ code, please use c++ code tags [noparse][code=c++] // Your code here [/code][/noparse] You have a couple of places where your loops are wrong: [code=c++] // This type is wrong, it will go one too far. for(int j=0; j<=asize; j++) // …

Member Avatar for noureenjee
-1
142
Member Avatar for SoulMazer

On line 2, r is coming from the values in the dictionary, not the keys. So you can't use it as a key on line 8, you can't index a dictionary by the definition. You could either test to see if the answer is a key and if it is, …

Member Avatar for SoulMazer
0
161
Member Avatar for rock9449

When posting c++ code, please use c++ code tags [noparse][code=c++] // Your code here [/code][/noparse] Don't try to print answer on the 'please enter in two numbers' lines.

Member Avatar for shasha821110
0
94
Member Avatar for RingmasterTJ

In your helper function: [code=c++] ostream& operator<<(ostream &output, const BSTree &other) { output << outputHelper(&output, other.overallRoot); return output; } [/code] It doesn't know what outputHelper is supposed to be. You could attempt to call it with [icode]other.outputHelper(output, other.overallRoot);[/icode] but outputHelper is private (as I suspect overallRoot is). I would tend …

Member Avatar for RingmasterTJ
0
2K
Member Avatar for TasostGreat

Unless your application could write to multiple files at once, I suspect that multiple threads won't be much help. It would be hard to get different threads to write to different parts of the same file where the parts don't even really exist yet.

Member Avatar for Salem
0
172
Member Avatar for AdRock

I was able to get the vector to work and support the polymorphism: [code=c++] vector<Account *> accounts; accounts.push_back(new SavingsAccount(25.00, 1.00)); accounts.push_back(new CheckingAccount(80.00, 1.00)); accounts.push_back(new SavingsAccount(200.00, 1.00)); accounts.push_back(new CheckingAccount(400.00, 1.00)); for each (Account * pacct in accounts) { cout << "Original Balance: " << pacct->getBalance() << endl; pacct->credit(5); cout << "New …

Member Avatar for AdRock
0
2K
Member Avatar for freshfitz

Making it images makes it harder for people to extract, so fewer people will do it, so there is some benefit. If the goal is to reduce automated screen scraping, they have at least increased the amount of effort required. Your last comment about intellectual property being a thing of …

Member Avatar for freshfitz
0
186
Member Avatar for tovishal2001

I changed the MessageBox output to a System.Diagnostics.Debug.Print so that it wouldn't wait for me to click anything (possibly still reading in the background). VC# Express claimed it was making a project for .Net 3.5 (I made a console application, but did not output to the console.) This load line …

Member Avatar for LizR
0
143
Member Avatar for jehe88

Put some more thought into it and ask a more specific question. How do you envision the program (or function) working? What data will be provided to the program? What data do you expect the program to output? Does the user interact with the program? If so, how? What do …

Member Avatar for Agni
0
440
Member Avatar for huian88

We generally do not provide canned answers to problems. Especially not homework problems. We prefer to help you help yourself. In your case, first think about the problem. Think about the steps you would follow to solve the problem by hand. Use that plan as a basic design for the …

Member Avatar for Murtan
0
180
Member Avatar for JAGgededgeOB172

Just as a comment to the whole process... You declared [icode]info *resident[max];[/icode] (thats an array of pointers to info) but I don't see where you ever allocated the info instances to put in the array. (I suspect this is the root cause of your 'bugging out') Also, Agni is right, …

Member Avatar for JAGgededgeOB172
0
119
Member Avatar for jorgeberber

Note 1: Indenting is your friend, make much better use of him. Note 2: if you're in your main() and you return, your program is done I'm not sure what's up with the two-level menu, where you only handle one case from the first menu and two cases from the …

Member Avatar for Murtan
0
188
Member Avatar for homeryansta

When posting c++ code, please use c++ code tags [noparse][code=c++] // Your code here [/code][/noparse] And actually in my testing, that doesn't exit like you want it to. It keeps looping if the character is [ICODE]>= ' '[/ICODE] OR if the count is [ICODE]<= SIZE[/ICODE]. It will not stop until …

Member Avatar for homeryansta
0
143
Member Avatar for neoseeker191

The counter and the array were both declared inside the sample code (calcList), they wouldn't be visible outside of it.

Member Avatar for neoseeker191
0
245
Member Avatar for kenji

Please post the entire class definition for Account and for Bank. From [icode]class Account {[/icode] to [icode]};[/icode] and the same for Bank. (For this part, I'm not really interested in member bodies, I just want a feel for what data items the class contains and the methods you have defined.) …

Member Avatar for Salem
0
95
Member Avatar for taichou

@nitu_thakkar That appears to be a sort for the characters in a string, to put the highest character in the string as the first character. @taichou The above sort could be adapted to sort strings in a list. Where do the words come from? How do we know how many …

Member Avatar for ajay.krish123
0
125
Member Avatar for AdRock

I was going to give you Agni's answer (lucky I saw it when I switched to Advanced). Also, there is no requirement that a class have only one constructor. You could actually declare both (not that you want to in this instance): [code=c++] Account(double newBalance) { currentBalance = newBalance; }; …

Member Avatar for AdRock
0
157
Member Avatar for RayvenHawk

I was going to recommend that you only load the bitmap once, but I noticed that your code already has a comment about it: [code=c++] //initialize the game... //load bitmaps, meshes, textures, sounds, etc.[/code] And your whole [ICODE]x = rand()..., y = rand()[/ICODE] appears to be all about picking a …

Member Avatar for Murtan
0
100
Member Avatar for shers

Let me ask this a slightly different way to see if it helps you think about it. You have 200 pictures, numbered 0 to 199. (I chose those numbers because that matches the index in almost all collection data types.) I propose your screen has a layout something like this: …

Member Avatar for LizR
0
185
Member Avatar for u8sand

Just wondering...Notepad and other editor like applications tend to respond to a normal 'terminate' message with a user query if their file has been modified, but don't terminate until they get an answer. Might this be a part of your problem?

Member Avatar for u8sand
0
147
Member Avatar for yasserovic

And even that looks like something the instructor gave you. With the "do not modify" and "add code here" comments:

Member Avatar for Murtan
0
122
Member Avatar for mn_kthompson

The only answer I come up with (and I did get the same result in my sample code) is that tabs equate to 8 characters. You start the class at the left margin The init function MUST be indented at least one space, but the actual count is not important, …

Member Avatar for sneekula
0
135
Member Avatar for BobLewiston

If you post your code with code tags, the whitespace doesn't go away. When posting c# code, please use c# code tags [noparse][code=c#] // Your code here [/code][/noparse] About the private members and array topic, I don't think I understand what you're asking. You can do things like: [code=c#] Console.WriteLine …

Member Avatar for miculnegru
0
82
Member Avatar for dvsConcept

I doubt you're supposed to search for the password to look for duplicates. The common case is where you refuse to add a user (name) because it already exists. So a function that took the array and a name to search for that returned where the name was found (or …

Member Avatar for dvsConcept
0
82
Member Avatar for smithss

Did you attempt to walk through what your code does in your head? Here's your code with my comments included: [code=c++] // Assign a to temp char *temp = a; // temp and a both point to the original buffer // Assign a to point to a new buffer n …

Member Avatar for smithss
0
139
Member Avatar for smithss

Yes, your understanding was correct, the function was changing its 'copy' of the pointer and not the actual start address. (Changing the actual start address is probably a bad idea anyway.) Your new trimleft would work as written. A few things to think about: This first might actually slow the …

Member Avatar for smithss
0
115
Member Avatar for animefun2

You haven't done enough yourself yet for us to provide constructive help without just doing the work for you. (We don't do that here, we help you fill in the gaps where you lack knowledge, but you have to narrow the gaps.) The assignment recommended constructors and destructors, declare them …

Member Avatar for Murtan
0
111
Member Avatar for al3x748769

Well, if you're not afraid of pointers... [code=c] int bin2dec(char * bin) { int n; int sum = 0; while (*bin) { n = *bin - '0'; if (n < 0 || n > 1) { printf("\nInvalid binary character: '%c'\n", *bin); puts("Binary only uses the digits 0 and 1.\n"); return …

Member Avatar for Murtan
-1
123
Member Avatar for HarryGabriel91

I think you're going to have to use all of the 'nature' values and then scale from the nature values to your -1 to 1 grid. If the farthest the planet gets from the sun is 152,000,000 km then you might scale to 160,000,000 km = 1. You could continue …

Member Avatar for MosaicFuneral
0
143
Member Avatar for csaawariya

Not much on the effort part there... The algorithm will be something like: [LIST] [*]Start at the head node [*]While there is a next node [*]If the next node is the head node, the list is circular [*]If we got to the end because there was no next node, the …

Member Avatar for StuXYZ
0
125
Member Avatar for noamjob

Whether or not the text of the PDF is 'available' is an option for the PDF publisher. I remember several tech documents that were designed intentionally to not allow you to copy the text out of them. It sounds as if your target document might fall into that category. You …

Member Avatar for Stefano Mtangoo
0
6K
Member Avatar for RenFromPenn

Welllll, you COULD enter CTRL-A to get Monday, CTRL-B for Tuesday... (but I wouldn't recommend it). I like some form of menu in this case, something like: What day of the week is it? (1-Sunday, 2-Monday, 3-Tuesday...) Then you could switch on the character entered and use it to set …

Member Avatar for Alibeg
0
134
Member Avatar for abhi_marichi

All of the comments I've found (with my Google search that you should have made) indicate that application level programs under 32-bit windows (aka Win32) cannot directly access the I/O ports. The primary suggestion appears to be that if you really need that level of access to the hardware you …

Member Avatar for abhi_marichi
0
150
Member Avatar for revenge2

The only place in your code where you attempt to print listMain is from inside sort, if the name passed to sort is 'pile1', right? When do you ever pass the name 'pile1' to sort? (You pass the list that is named pile1 to sort, but it is not equal …

Member Avatar for Murtan
0
332
Member Avatar for #include<James>

Coming from python are we? In C++, the quotes (") and (') are NOT interchangable. The following lines in your code: [code=c++] choose[0] = 'alpha'; choose[1] = 'list'; [/code] Generated the following warning in my compiler: [code] rand.cpp(27) : error C2015: too many characters in constant rand.cpp(27) : error C2593: …

Member Avatar for Murtan
0
132
Member Avatar for Whilliam

So 'list' is an index into the virtual heap, and each entry in the virtual heap is a structure that has an elem (the value at that node) and a next (the index in the virtual heap for the entry with the next higher elem). When there are no entries …

Member Avatar for Whilliam
0
117

The End.