- Strength to Increase Rep
- +9
- Strength to Decrease Rep
- -2
- Upvotes Received
- 33
- Posts with Upvotes
- 28
- Upvoting Members
- 21
- Downvotes Received
- 2
- Posts with Downvotes
- 2
- Downvoting Members
- 1
- Interests
- Programming
218 Posted Topics
Re: Did you try google? There seem to be a lot of hits relating to this. [url]http://www.google.ca/search?q=sdl_ttf+opengl[/url] You can use SDL_ttf's TTF_RenderText_Blended to get smoothed SDL text surfaces. I don't know how to convert them for use in OpenGL from there, unfortunately. I think you should be able to find this … | |
Re: [code] getchar(); }[/code] [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385[/url] [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1042856625&id=1043284385[/url] [quote]. . . I use the example Hello.dev from Examples directory soon after installation. How would I get this working from command line.[/quote] So, you have a .dev file that you want to compile from the command line? | |
Re: [quote]you might also check the length of the PATH environment variable. On my computer it's so long that there isn't any room left to add more. So I have a batch file to truncate the PATH to bare necessity so that I can run other command-line programs from command prompt. … | |
Re: Declaring variables inside for loop initialization sections is indeed C99-only. I wouldn't do it if I were you. [quote]Btw, what are the differences between float and double? [/quote] double just has more precision (usually). Oftentimes, a float is 4 bytes and a double is 8. There used to be a … | |
Re: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046996179&id=1043284385[/url] | |
Re: Also see this FAQ: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048865140&id=1043284351[/url] | |
Re: Your code is actually C. You're not using any C++-specific features. That's not necessarily a bad thing, just thought you should know. :) If you want to stick with C-style functions you might find strncmp() useful instead of comparing individual elements of a char[] array. You should probably also make … | |
Re: As for keeping score, you could have two variables. [code]int games_won_by_computer; int games_won_by_player;[/code] Once you're done that game, you could try a guessing game where the user guesses a random number in as few tries as possible. | |
Re: Well a start would be to change the <= on line 13 to >=. But then you still get weird output. I'm not sure how exactly you want to break this problem down recursively. You could have one function for each line, as you're doing, but then you need to … | |
Re: You could try here: [url]http://chrishecker.com/Rigid_Body_Dynamics[/url] I've never done this, but my intuition would be this. Gravity is applying a downward acceleration on the box; this amounts to a force applied directly downwards starting from the object's centre of gravity (for a box, this is just the centre). You can calculate … | |
Re: This doesn't actually print anything. [code] if (n >= 95 && n <= 100) //print corresponding letter grade string m = "A+ ";[/code] Also, you can't just assign a string like "A" to the member variable grade, as I suspect you tried to do, since grade is an int. I'd … | |
Re: Probably args[0] doesn't exist. This is the array of arguments passed to the program, so perhaps when you run the program with "java Sha" you should add whatever args are required, as in "java Sha arg1". | |
Re: As mentioned, the issue is that the memory you allocated previously with [inlinecode]new int[inter][/inlinecode] is still an array with zero elements when you try to use it with [code]intersection[a] = elements[a];[/code] A slightly hackish and wasteful way around this would be to allocate size+s2.size elements for intersection (since that's the … | |
Re: Do the functions isValidProcess() and isValidfile() throw exceptions if they find something amiss? It should do no harm to set this->fileName, which is just a string, to fileName, and then do the check afterwards. If the check fails you can always reset the variable. Why do you want to use … | |
Re: Use code tags when you post code -- otherwise it will be an unreadable mess. This is also the C programming forum, not the C++ one, so C++ code is out of place. It's also old-style C++ code. You're using <iostream.h> and <fstream.h> etc, which are pre-standard. Use <iostream> and … | |
Re: If the compiler isn't provided with a function definition or prototype at the point the function is called, it will say something like [code]warning: implicit declaration of function `foo'[/code] and if you pass it arguments [code]warning: too many arguments to function `foo'[/code] and various warnings if you use a return … | |
Re: If you don't care what the beep sounds like just print a '\a' character. [code]cout << '\a';[/code] or [code]putchar('\a');[/code] | |
Re: You may need to sort the data by number first, if that's the output you want. I think, however, that you should be reading in a sequence of names, assigning a number to each name automatically: so the first name entered will become 1, the second 2, and so on. … ![]() | |
Re: The signal itself has to emit an argument if you want to connect it to a slot which accepts an argument. Otherwise, you need an intermediate function which adds the parameter in and then calls the appropriate slot with an argument. At least, this is to the best of my … | |
Re: Mandriva, like most flavours of Linux, has a cairo package that you should be able to install with ease. [url]http://www.google.ca/search?hl=en&source=hp&q=mandriva+cairo+package&btnG=Google+Search&meta=&cts=1262806955486&aq=f&oq=[/url] The only time you really need to install something from source or from a third-party website is when it's really unusual software that there is no package for, or when … | |
Re: Also, this (starting at line 132) won't do what you want it to. [code] while(!opFile.eof()) { getline(opFile,templine); cout << "\nTEMPLINE: " << templine; //if ((offset = line.find(search, 0)) != string::npos) { // cout << "found '" << search << "' @ offset " << offset << endl; //} } [/code] … | |
Re: Well, first of all, the whole if-statement only executes if [icode]E1.loc == E2.loc[/icode], which I'm assuming means that the elevators are at the same position. I'm not sure whether this is what you want. Next notice that your code has some conditions when it does nothing. Suppose, for example, that … | |
Re: My own personal flavour of a quine. It's not the prettiest, I haven't used Python in a while. :) [code]#!/usr/bin/python import sys before = "#!/usr/bin/python\nimport sys\nbefore = \"" after = "def escape(string, multiline = False):\n\ string = string.replace(\"\\\\\", \"\\\\\\\\\")\n\ if not multiline:\n\ string = string.replace(\"\\n\", \"\\\\n\")\n\ else:\n\ string = string.replace(\"\\n\", … | |
Re: I have never used SFML, so I can't say anything about that. But I can highly recommend the SDL: it's a great library. If you're just starting to learn it, you really should check out this tutorial, it's one of nicest out there: [url]http://lazyfoo.net/SDL_tutorials/index.php[/url] [edit] The SDL has good multiplatform … | |
Re: Again, don't use <iostream[b].h[/b]>. Plus main() returns [b]int[/b]. Don't cast malloc() (in C; in C++ you should use [inlinecode]new[/inlinecode]). And be sure to free() (for malloc()) or delete (for new) your memory. [code] #include<iostream.h> #include<stdio.h> [color=red]#include<conio.h> #include<alloc.h>[/color] [/code] In C++, <stdio.h> should become <cstdio>. And the last two headers you … | |
Re: I'm also thinking that this [code]string todo = "/.todo.txt"; [/code] should be "./" instead of "/.". | |
Re: [QUOTE=Belthemet;966506][B]#Off topic[/B] When I was logging in, I have noticed 600,00x members registered on this forum. Congrats on the 600k! ;)[/quote] Yes, new members register at an astonishing rate here . . . when I logged in there were six less members than there are now. :) [quote]Hello. My console … | |
Re: [url=http://www.instant-registry-fixes.org/troubleshooting-and-preventing-ntdlldll-errors/]This page[/url] says that ntdll.dll is "a Native API file of Microsoft operating systems and it contains NT kernel functions". Kind of vague, but perhaps if the code is doing any system calls (accessing files, perhaps), that may account for it. Or perhaps if your program uses a lot of … | |
Re: [code]char filenames[fcount][16];[/code] You're declaring a variable-length array here. It's not standard C89 to do that. If I were you I'd just declare the array as [code]char filenames[MAX_FCOUNT][16];[/code] Also: [code] //Loop through the file names for(i = F_SIZE + 4; i < F_SIZE + 4 + (fcount * 16); i+=16) { … | |
Re: You use -99 in your input file to indicate end of line, but you seem to expect -999 in your program . . . . Just a thought: why don't you read in one line at a time, and treat that as the row of a matrix. That way you … | |
Re: You can't assign anything inside a structure declaration. A structure declaration just defines a type. It's like a blueprint; you're telling the compiler, "if I ask you to create a Something, this is what I want it to look like." An example of a structure declaration would be [code]struct Something … | |
Re: Well, it has one advantage over a return value -- you have to pass in an address, whereas you could ignore a return value. :) I don't think that's how I would write it, though. | |
Re: Too bad you're not using PHP. :) [url]http://ca2.php.net/filesize[/url] But it seems like it might not be possible: [url]http://bytes.com/groups/php/595984-filesize-not-reading-http-pages[/url] On the other hand, wget determines file sizes. Apparently it requires HTTP 1.1 (not 1.0) to do this. I really don't know. You'd have to do some research. | |
Re: Well, that's not too difficult. You could open the file, read it line-by-line, and print only those lines which contain the word "WARNING", for example. If you wanted to be more robust, you could separate out the column and compare that. Some code that may help: [code]std::string text = "A … | |
Re: A constant variable can't be changed after initialization. If you didn't initialize it, too bad, you still can't change it. (If you compiler is a good one, it may warn you that you haven't initialized a constant variable.) In other words: "const" doesn't mean, "I'll only set this variable once." … | |
Re: Use [code][/code] tags. #include<conio.c> -> #include<conio.h> | |
Re: [code]for( int i = 0; i < [color=red]32[/color]; ++i )[/code] That's not very portable. Use something in <climits> or the C++ equivalent. | |
Re: My only suggestion is to try a profiler so that you can see exactly where your program is spending all of its time. If you have access to the code from the other program, profiling it as well might be enlightening. If you're using a Windows port of GCC like … | |
Re: Why is root a global variable? As far as I can see, it doesn't need to be, and it's just causing confusion because several functions take a root parameter. | |
Re: Why don't you use the [url=http://en.wikipedia.org/wiki/Quadratic_equation#Quadratic_formula]quadratic formula[/url]? If all of the equations are quadratic, it should work. You can do square roots in C with the sqrt() function from math.h, and arbitrary powers (if you wanted to) with pow(). The first part of the problem, of course, is parsing the … | |
Re: [code] while ( !feof(ep) ) { fgets(registryHive, MAX_PATH, ep); [/code] Note that this is [url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351]not a good idea[/url]. My suggestion: [code] while ( fgets(registryHive, MAX_PATH, ep) ) { [/code] Yes, it does the same thing. :) | |
Re: You don't want a semicolon after a while loop: [code]while( number<= 0 )[color=red];[/color] {[/code] -> [code]while( number<= 0 ) {[/code] | |
Re: [code]if(fib = fnum) [/code] Try ==. = is for assignment, == is for comparison. (Your compiler should warn you about this if you enable warnings.) Plus I don't think this is what you want. [code]for (fib=1; fib=num2 + 1; fib++) [/code] The comparison portion of that for loop is actually … | |
Re: You can even use fancy preprocessor macros and so on to replace the malloc()/free() calls in existing code with your own functions. BTW, __LINE__, __FILE__, __DATE__, and __TIME__ are all standard C89 as far as I know. | |
Re: The best way to do this is perhaps this: declare a structure representing the information. (Perhaps a header structure, a data one, a tail, and a packet structure that contains all three.) If you want to skip a given number of bits, use an unnamed bitfield. [code]struct { unsigned : … | |
Re: [code]What? Never heard of that. Don't tell me, this don't work x = bool (x||y) ; [/code] That is C++ only. The C way looks like this. [code]x = (bool)(x || y);[/code] Perhaps the OP is compiling as C instead of C++. As for the original code, it would work … | |
Re: You can read from and write to the same file at once, but it's difficult. You're best off creating a copy of the file and modifying that, then replacing the original file with the modified one, as you've done. You could definitely simplify the code by creating a function which … | |
Re: Use code=c++ in your code tags to get syntax highlighting. It makes the code a lot easier to read. iostream.h doesn't actually exist (according to the C++ standard). Consider using [code]#include <iostream> using namespace std;[/code] instead. Anyway. The problem is that you're writing a lot of numbers to a text … | |
Re: What are you forgetting here? [code]for(j=0;j<41;j++) for(i=0;i<79;) txt[j][i]=32;[/code] Hint: it's an infinite loop . . . . [edit] And it's a lot easier to use character constants like ' ' and '\r' in your code instead of magic numbers like 32 and 13, don't you think? [/edit] | |
Re: You could save the numbers as you find them instead of printing them, say in a char array, and then print that array in reverse. On the other hand, it would probably be better to use a different algorithm. What you need to do is find the most significant (highest … |
The End.