- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 26
- Posts with Upvotes
- 20
- Upvoting Members
- 19
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
PhD student in Computer Science Education
75 Posted Topics
Re: The intent of C++ code is very simple, even though it doesn't compile. It simply takes the sum of the values in an array. When you understand the purpose of a program, it's much easier to port it, since you aren't blindly translating code. You really don't seem to show … | |
Re: If you want to develop a game completely using C, the [Allegro library](http://alleg.sourceforge.net/) is a pretty comfortable choice. Other folks use engines like [SDL](http://www.libsdl.org/) and [OpenGL](http://www.opengl.org/) to power games. I find Allegro to be easier to get started with, since it's much easier to go from nothing to a graphical … | |
Re: Hi! I love the new site - very nice-looking. I got an issue when I tried to update my avatar - just look to the left and see. :P I'm on firefox 10.0.2 on Ubuntu LTS 10.04 with noscript disabled. I tried uploading pngs and jpgs between 50x50 and 100x100 … | |
I've been unable to connect to the Daniweb IRC server for the past few days. Is it temporarily down? My life just doesn't feel complete unless I'm idling in there and not doing anything. :| | |
Re: This is an initiative I can definitely get behind. I've been idling there for over a year now, but things seem to have been picking up recently. Maybe there's hope after all. ;) /me changes his signature. | |
Recently, whenever I try to visit any user's profile here on DaniWeb, I get an ugly and intrusive browser dialog trying to push Flash on me. It's more than intrusive... it's very weirdly-worded. [quote] You need Adobe Flash Player 8 (or above) to view the charts. It is a free … | |
Re: Your recursive method has no base cases. Even if they did, your entire program is written in tail recursion, so whenever you return to a previous point in the stack, you don't have any control there because the only time you make the recursive call is in a return statement. … | |
Re: You know, since day one, I've tried to avoid looking at the reputation system as if it were some kind of a video game. It seems to be in bad taste and undermines the point of being part of the community. ... but this feature makes that [B][I]really[/I][/B] hard. I … | |
Re: On my system, this opens the 'nano' editor. To close out of nano, press 'Ctrl-x'. If you changed your command, then hit 'y' and Enter to save the changes. Once you exit, the command will run. | |
Re: Out of your choices, I'd pick Nethack, but I've always been quite partial to [url=http://roguebasin.roguelikedevelopment.org/index.php?title=Dungeon_Crawl_Stone_Soup]Crawl[/url]. | |
![]() | Re: What version of Ubuntu are you using? If you're using a version that has 4.3 in the repositories, you will have a very hard time trying to upgrade it to 4.5. It might be easier to install a new version of Ubuntu than it is to upgrade the compiler. |
Re: So it looks like you're going out of the bounds of the array. Try to find out what the values of k and l are when the code fails. You could use the debugger, or just put a [icode]printf("%d %d\n,k,l);[/icode] before the if-statement and trace what the values are while … | |
Re: OK, your function definitions are causing some errors for me. Whenever you are simply writing a function prototype, you use a semicolon. But when you are defining a function, you don't. [code] my_prototype( int a, char b ); my_function( int a ) { } [/code] After I did that, the … | |
Not sure where bug reports should go, so I'm posting mine in feedback. This morning when I logged in to DaniWeb, instead of getting the redirect page, I somehow obtained a 'login.php' file for the page instead. Opening the file in emacs, it contained (in this order): - A bunch … | |
Re: It looks like you have some code that's sitting outside of functions. For example, the switch statement that's between lines 17-30 is not contained within a function. You can't have code just sitting around like that. You've also got a function inside of another function... i2c_readbyte is inside of i2c_writebyte. … | |
Re: I remember having the same problem back when I was goofing off with OpenGL. I'm not sure how much it will help you, but I'll contribute this anyway. I wrote a brute-force method that allows me to rotate along any object's local axis, and then I can use that as … | |
Re: Happens to me every once in a while in Firefox on Ubuntu 9.04. Sometimes it goes away and sometimes it doesn't. It doesn't mess with my typing, though. Just thought I'd throw that out there. | |
Re: The path to the shell that is currently running in a terminal can be found in the 'SHELL' environment variable. You can run 'echo $SHELL', which, on my machine, prints out '/bin/bash'. Is this what you're looking for? | |
Re: I'm assuming that 'student_file' is an array of strings? Do these changes help at all? [icode]11. sprintf(student_file[k], student_file, "%s %s %c", last, first, middle);[/icode] [icode]16. printf("%s\n", student_file[i]);[/icode] If they don't help, can you post your declaration of 'student_file'? | |
Re: My knowledge of signals is rusty, but here goes nothing... I think that after a handler is executed (in this cause, 'handleSIGCHLD'), the handle is released, and the function is no longer associated with the signal. Therefore, from inside the handler, you need to call the 'signal' function at the … | |
Re: Here's a simple pseudocode solution. [code] boolean[10] array /* Array of all false values */ int count = 5 /* Number of true values we want */ while count > 0: int k = Math.random()*10 /* Random integer from 0 to 9, inclusive */ if array[k] == false: array[k] = … | |
Re: Double variables just don't have that much precision. If you need numbers that are that fine-tuned, you need to look for an "arbitrary/multiple precision" library - something like GMP [url]http://gmplib.org/[/url] Hope this helps. | |
Re: It's not really Python-specific, but I would use the 'tee' command here. On *nix, the invocation of the script would be [code] python myscript.py | tee out.txt [/code] I'm sure Windows has a similar command as well. Hope this helps. | |
Re: I changed your function in the following way: [CODE] public String parsePath(String path) { String parsedString=""; String[] arr = path.split("\\\\"); System.out.println(arr.length); for(int i=0;i<arr.length-1;i++) parsedString+=arr[i]+"/"; return parsedString; } [/CODE] The first change I made was to path.split. You will probably think that this looks pretty ridiculous. This function takes a regular … | |
Re: Your function 'slope' should return the value of 'm' when it finishes. [code] def slope(x1, y1, x2, y2): a = (float(y2 - y1)) b = (float(x2 - x1)) m = float(a / b) return m [/code] | |
Re: What platform are you compiling this on? Some compilers have built-in stack-smashing protection that would prevent this code from working as expected. If you're using GCC, for example, try the following command: [icode]gcc -fno-stack-protector programcode.c[/icode] | |
Re: [icode]A*B[/icode] means 'A times B' [icode]A**B[/icode] means 'A to the power of B' Hope that helps you out. | |
Re: You're getting a timeval structure back. You need to do a little formatting before you can use it. Here are some highlights from the man page... [url]http://linux.die.net/man/3/localtime[/url] [LIST] [*] tm_year is the number of years since 1900... so add 1900 to your tm_year result. [*] tm_mon is the month where … | |
Re: A Python for-loop is pretty much like Java's for-each loop, where instead of going through the loop with an incrementing value each time, you go over a list of values, instead. Here's a simple example. [code] classes = ["English","Math","History","Physics"] for s in classes: print s [/code] If you prefer the … | |
Re: [CODE] file.write ( "%-10s%6d" % (item[0], item[1]) ) ^ ^ [/CODE] Worked fine for me after I put these parentheses in. | |
Re: First of all, 'main' returns 'int'. Always. Secondly, when encrypting a file, you should open both the input and the output as binary files. [icode] FILE* input = fopen(input_file, "rb"); [/icode] Reading them as ASCII files is problematic, since the program is translating Windows newlines to special characters, which shouldn't … | |
Re: You were on the right track using strcmp in your second example. But you said that it wasn't returning true. Strcmp returns '0' when two strings are equal (which equates to false). It's a classic gotcha. So your second example should read: [CODE] if (strcmp(sCmdInt[0], "ReadMemory32") == 0) { // … | |
Re: Short answer: Because you're leaving the elements in the array uninitialized. Long answer: Consider the following code snippet. [code] int foo[10]; int main( void ) { static int bar[10]; int gus[10]; int i; for ( i = 0; i < 10; i++ ) { printf( "%d %d %d\n", foo[i], bar[i], … | |
Re: The most important step (in my opinion, of course) is to create a well-defined protocol for Client->Server communication and STICK TO IT. Sanitize all data that comes in from the client, since there are no guarantees that the player is using an 'official' client. Make sure that whatever data structure … | |
Re: Are you saying that you want to store all of the values in the list as individual variables? If that's the case, why is your program designed in such a way that you would need that sort of functionality? Variables are abstractions that only make any sense in the context … | |
Re: Sorry for pointing out the obvious, but according to the dump, the code is failing at one of your calls to setSelectedFile(). It seems like either file1 or file2 are null. Are you sure images 1.png and 2.png always exist in a folder called "test images" on your desktop? | |
Re: Have you tried using a Map? It might be overkill for your problem, but this fits your query pretty well, and is scalable to larger cases. This will allow you to pass in a string to fetch a named object, and also stores them in a nice space too. [code] … | |
Re: The loop [icode]for( i = 1; i == 3; i++ )[/icode] never does anything. That loop says, in English, "Start i at 1. As long as i is equal to 3, do the loop and increment i." i doesn't start out equal to three. You need the condition to be … | |
Re: When you use [icode]cin >>[/icode] to save a string, it only gets the first word up to the whitespace. You need to wrap everything between lines 8 and 17 in another loop that performs the collection from standard input until you run out of characters. | |
Re: First of all, when dealing with variables that are larger than one byte, the endianness of the machine might cause portability problems. I'm going to assume you're on an x86 little-endian machine for now. To get a specific number of bits from a variable, you first need to create a … | |
Re: You aren't showing your complete class. It looks like you may have accidentally made something global that should have been local to your auction list. Here's how I would create a class based on your specs. Does your code look something like this? [code] class AuctionList(object): def __init__(self): self.mylist = … | |
Re: In lines 151-154, I see you're only blitting the background over top of the paddles and the ball - not over the score. Add this before line 151: [CODE] screen.blit(background, text.get_rect().move(320,10)) [/CODE] While it's more efficient only to blit over things that are live and in play, sometimes it's worth … | |
Re: EDIT: Oops... Aia beat me while I was typing. Here's my post anyhow. Strings in C are arrays of characters, but the thing that makes it a 'string' is the fact that it ends in a null byte. [CODE] "Hello" = ['H','e','l','l','o','\0'] [/CODE] Your reversal method starts by swapping mike[0] … | |
Re: [QUOTE=jephthah;1175070] [code]#define SQR(x) (x * x)[/code] [/QUOTE] Careful now... what happens if you run SQR(3+2)? [icode](3 + 2 * 3 + 2) = 11[/icode] Every time a parameter appears in a macro, it should be surrounded by parentheses. [code] #define SQR(x) ((x)*(x)) [/code] | |
Re: Here's the formula I usually use for this problem. [LIST] [*]Set a variable 'numcon' to the number of connections to allow. [*]After a successful 'accept' call, decrement numcon. [*]When numcon equals zero, stop accepting new connections. [*]Continue running the server until all clients have disconnected. Alternatively, set a timer and … | |
Re: [QUOTE=UncleLeroy;1170787] 2) "heap" is the name we use for "malloc space", so your use of the term is non-standard, and this is homework, I pity your grade. 3) There is no code that reads the file. There is a line that opens it, but no code that reads it or … | |
Re: Sounds like a job for vector math! What you want to do is figure out the unit vector that points in that direction. Then multiply that unit vector by the speed you want it to go. Here's the way I would do it. First of all, store bullet positions as … | |
Re: You shouldn't be using a while loop inside of the for loop. That will just result in the same line being parsed over and over again. Look carefully, and you'll see that because line doesn't change, the condition can never change, so the loop will never end or it will … | |
Re: Look at line 53. You've created a NULL char pointer, and then right after that you try to run a strcpy saving the data to it. That won't work since compareFN isn't pointing anywhere. Since you're just taking a pointer, just save the return value. Try doing this instead. [CODE] … | |
Re: You say you're doing it recursively, but it looks iterative to me. Here's a pseudocode example of what you want to do. [code] global list L; /* To store the pathnames. */ DirectoryCheck( D ): L.add_path( D ) for each subdirectory S in D: DirectoryCheck(S) [/code] So in your code, … |
The End.