338 Posted Topics
Re: [QUOTE=Premlal;1066905] This code will not compile because I am trying to assign a myTemplateClass <int> pointer or myTemplateClass <char> pointer to myTemplateClass pointer. Can we declare a pointer array that can hold myTemplateClass pointer of any type? Using void pointer will not help much, since it needs a lot of … | |
Re: Unless I'm mistaken, your code won't compile. The first problem is that the compiler doesn't like you to declare the size of an array at runtime, it wasn't to know how big the array will be at compile time. (You can get around that by using an array that you … | |
Re: Also, when posting your code for us to look at, please use code tags: [noparse][code] // Your code goes here [/code][/noparse] It makes the code MUCH easier to read. (There are several people that won't even look at your problem unless you use code tags.) | |
Re: When posting python code, please use python code tags You have to post your code with code tags so we can see the indents. And as this is your second thread on the same topic and you didn't answer my question in the first...is searching a single file what the … | |
Re: I don't think I understand the second example... [QUOTE] input: i have 2 bananas and 3 oranges print: 1+2+3= 6 [/QUOTE] Where'd the 1 come from? Code comments: line 6: [code]data = input("Please enter a string\n")[/code] Should use raw_input to get string data. You appear to be dividing the characters … | |
Re: You're losing the first character of the full name inside the first for loop (of concat()). The second and third loops add each character to what was in fullname, but the first loop assigns each character to fullname. The second character in title overwrites the first. (If the title were … | |
Re: Templates require the users to see all of the member functions. You can't have the methods 'hidden' in a c++ file. If the code creating the instance of the template doesn't "see" the method, the method does not get implemented. This is due to the way templates are implemented. They … | |
Re: Lets try to describe the problem better... Is the problem: a) search the directory for a file name b) search a specific file for string data c) search all of the files in a directory for string data d) search all of the files in a directory tree for string … | |
Re: Based on what you have there, I suspect you're supposed to write the two functions: int empty_array_insert(int[], int); void display_in_reverse(int[], int); | |
Re: Assuming that your sort works... [CODE] if (n[0] == n[1] && n[3] == n[4] && (n[2] == n[1] || n[2] == n[3]))[/CODE] | |
Re: Work the problem in steps. I see the steps as something like: Prompt the user for where to put their symbol Accept the user input Validate that they entered something acceptable and that the location they asked for is available Set the location to their character You would then probably … | |
Re: The %d in [icode]print("wait %d seconds ..." % sec)[/icode] will be replaced with the numeric value of sec. I didn't see the %s, but it is used for string values. @Gribouillis Shouldn't line 39 test start + 3 against the length of the list? We're going to be referencing array … | |
Re: as far as I can tell, you're only "drawing" the sides of the square, you didn't do the top or bottom yet... In the sides code, the internal loop (for the spaces) is destructively decrementing your limit. (I'm referring to the s-- that limits your loop.) You should either reset … | |
Re: I'd be much more willing to look for the problem if you listed the line number the compiler complained about. Generally giving us all of the information you have about the problem is a good idea. | |
Re: Wow, deja vu, but better problem description. The last word won't be followed by a space... add another [icode]if (counter > longest_word)[/icode] outside the for loop to handle the last word. or alternatively...you could just add a space to the end of the string to make sure that there is … | |
Re: The only obvious thing I see is that it doesn't try to save the length of the last word, it would appear to work for everything else. The last word in the sentence won't be followed by a space, it will be followed by the end of the string. Add … | |
Re: I'm presuming that x is the number of array entries you filled. A more descriptive name would be more appropriate. line 15 in your code would be executed for every pass of the loop. If the first one doesn't match, then line 15 assumes you can't find it and terminates … | |
Re: It looks to me like the status function only writes the prompts that precede an input. The test for status in the code jonsca posted causes the input to be skipped so that might fix your problem. (If not, try entering a value where the program appears to be paused … | |
Re: We like to help people who appear to at least be attempting to help themselves. I suspect line 7 won't even compile. What is the code supposed to do? What does it do now? | |
Re: Should your turtle support a pen up / pen down setting? Should your turtle support a pen color? It should be straight-forward to write the 'forward' code... You have a current location and a direction and a distance. [code=] for each step in the distance: If the pen is down: … | |
Re: I was working on a reply similar to Narue's but she says it so much better I threw mine away. But she's right. Generally the rule is first, make it work, then if necessary make it work fast. This isn't a license to do obviously stupid things, but if you've … | |
Re: It is BAD FORM to bring a thread that is over 3 years old back to life. If you have a problem, you might follow the suggestions in the thread to get started. Once you've made some progress, start your own thread. For homework or assignment type problems, we expect … | |
Re: Please use code tags so we get indenting and line numbers [noparse][code=c++] // Your code here [/code][/noparse] and if you're wanting help with compile errors, maybe you could post the error message? | |
Re: The error you were reporting was based in your original code: [code=python] if letters[x] == ' ': y = 0 message_number.append(y) x = x+1 if letters[x] == 'A' or 'a': y = 1 message_number.append(y) x = x+1 if letters[x] == 'B' or 'b': y = 2 message_number.append(y) x = x+1 … | |
Re: Either the record doesn't exist (the [icode]dfSicilNo.Text[/icode] does not exist) or if the record does exist, the field is null. You should be able to ask the query how many rows (records) it returned (if it is zero, then the record wasn't found). If there was a row returned, you … | |
Re: I tried to read your code to understand your algorithm, but I didn't recognize it, and the limited commenting you provided didn't make it much clearer. If you run the program with the sample from the link, do you get the same output? What other test data did you provide … | |
Re: Given your input data (14 grades, one of which was an A) I would have expected 3 * for A percent = 100 / 14; // 7 in integer math Acent = percent * a / 2; // 3 in integer math Do the other grades display the number of … | |
Re: The previous posters point was that you have an IF statement on line 17... an if is either true or false... The 'true' clause has a return on line 19 and the 'false' clause has a return on line 23... So in either case, the function has returned before you … | |
Re: Well, ignoring that your input doesn't do much to protect the user from themselves (for example, enter "fred" when it asks for the account number and see what happens)... Do you know in advance (or can you ask) how many they want to enter? If you could, you could wrap … | |
Re: The code as posted has a few problems: In combination with [ICODE]const int MAXADDRESS = 25;[/ICODE], the statement [ICODE]char people[MAXADDRESS];[/ICODE] declares an array of 25 characters. But later in methods of the class, you treat people like it was an array of PERSON. See: [ICODE]people[head] = p;[/ICODE] and [ICODE]p = … | |
Re: I don't see where your enqueue function sets the next and prev members of the node. When the queue is empty, front and rear should both be NULL. When you add the first node, front and rear should point to the new node and its next and prev should be … | |
Re: We like to help those that show some effort, especially when it appears to be an assignment. Show us what you've tried. Tell us what it does and what you expected it to do and we can help you make the two match up better. (I wouldn't be surprised to … | |
Re: If the parent process doesn't have to wait, why does it care who finishes first. If at least one child process needs to finish, then you have to wait. | |
Re: Please use code tags when posting code You will need to re-input the health inside the loop so that it will ask the user for the health again. I suspect the current version outputs the 'health status' waits for enter and then outputs the same status again. | |
Re: I'm not sure what your problem is, when I compile and run it: start Caught One! Ex. #: 1 Caught One! Ex. #: 2 Caught a string: Value is zero Caught One! Ex. #: 3 end | |
Re: For the most part in c++, a class is almost the same as a struct. The key difference is that members in a struct default to public, in a class they default to private. You made all of the members of your class public so it shouldn't really matter. Your … | |
Re: Your problem is inside the while loop. [code=c++] while (whileIter != tmpCsvFile.end()) { whileIter++; if (fileName == (whileIter->fileName).c_str()) break; } [/code] You have advanced the iterator (possibly to the end) before you try to test the filename. Put the fileName test (with the break) before the iterator advancement. | |
Re: Why not just 'add' the records you want in main, after you construct the list? [code=c++] int main() { List test; test.InsertEmployee("Michael bay",1234,"Design"); test.InsertEmployee("Enrique",5678,"Production"); test.InsertEmployee("Fernando ",9012,"Management"); test.DisplayList(); getch(); return 0; } [/code] Note that DisplayList() as written is broken and will only display one record. I think that InsertEmployee() will … | |
Re: I can't find the examples right now, but I recall modifying the setup.py to perform a search for some DLLs and using the path I found in the data section. so instead of the constant string [icode]'msvcr71.dll'[/icode] you would use a string variable which contains the full path (as built … | |
Re: Generally, I like it. (You're right, a GUI would help a lot to follow what's going on. ) Just a couple of nit-picky items: I don't think it is good form to have the Tank's __init__ method prompt the user for a tank name. I'd rather see the prompt in … | |
Re: I think the forcibly stopped comes from the reader application reading one line and exiting. Can you put the read into a loop of some form? If you're going to write to the stream more than once, you should probably read more than once. You'll probably want to add detection … | |
Re: It looks like it compiled, so the symbol was defined enough for the compiler to recognize them. The link process is where the actual executable is built. The linker needs to match up the symbol that your main calls with the actual implementation. You should probably add the pcsfile.cpp to … | |
Re: The code you posted wouldn't even compile, let alone run. Please be specific in the problem you are having. I think the following is close to what you wanted, but it uses global variables which have their own problems: [code=Python] import Tkinter as tk root = tk.Tk() root.title('background image') def … | |
Re: I don't know what your problem is in particular, but it may be that you need to allow autocad some time to process the first command before it is ready to accept the second command. Alternatively if you are using OLE or COM to interface with AutoCAD, you need to … | |
Re: I would reset the player and monster health at the start of the battle. The weapons would make a good class, the weapon has a name, a cost and an amount of damage. Then you could make a list of weapons that could be iterated for display at the shop. … | |
Re: Not surprisingly, but your program is doing what you told it to: [code=c] // Wait here for the user to enter a message gets (msg); while (msg != "q") { /* Write out message. */ if (write(sock, msg, sizeof(msg)) < 0) pdie("Writing on stream socket"); /* Prepare buffer and read … | |
Re: Will the users of your application be connecting to your SQL server or is the intent for them to connect to their own server? The following presumes they will be connecting to your server: Hard coding the connection string makes it a little harder to find, but unless you're encrypting … | |
Re: You're having an entity vs value comparison issue: [code=python] a = [[1,2],[2,0]] b = [2,0] aa = a[1] # at this point, b = [2,0] and aa = [2,0] # but aa == b returns False # aa[0] == b[0] returns True # aa[1] == b[1] returns True [/code] Python … | |
Re: Maybe you should look at the python bit-wise operators in the [URL="http://docs.python.org/reference/expressions.html#binary-bitwise-operations"]Python Docs[/URL] | |
Re: I think the problem with the 'both' option is that when you select 'both' on the form, gender is set to '' and not to 'both'. |
The End.