255 Posted Topics
Re: Lets just take a look at this code: [CODE=C]ptr=n*(malloc(sizeof(n)); ptr=head; scanf("%d",&ptr->data); head=ptr->data; ptr=ptr->next; [/CODE] You don't need line 1 because you just set it to point to a space of memory that has already been allocated ([ICODE]head=n*(malloc(sizeof(n));[/ICODE]). Lines 2 and 3 look alright to me. Line 4 doesn't work (I … | |
Re: Purely for the sake of simplicity, I would go with this route (doesn't use a second set of variables): [CODE=C] int main( int argc, char *argv[] ){ int *numberlist, i, n, min, max ; n = atoi( argv[1] ); numberlist = ( int * ) malloc( n * sizeof( int … | |
I have designed my page using Firefox and it looks exactly as I would expect it to, colors consistent with my design using Photoshop. When I view the page in Internet Explorer, all the colors are changed. It looks as if everything has a slight gray layer over it making … | |
Re: I tested it myself and it worked regardless of the resolution. What browser did this occur in? | |
I need to have my background image span the entire length of the page without using the BODY element, here's why: I separated the image into left and right sections so even for different resolutions, the left image will always be on the left, and same with the right. Because … | |
Re: Are you trying to emulate a DOS environment using C? Post the relevant code you have already, what it is supposed to do, and what it is doing wrong. | |
Is there any way to force fwrite() to write in big-endian format no matter what? I am trying to write a MIDI file and they are always big-endian. Converting every value I write to big endian beforehand would be extremely tedious. Ideas? | |
Re: There is not a way I know to do this with plain old HTML. Are you using ASP or PHP? You can force the browser to request download rather than just opening the file using some header info. | |
Re: You can replace that with a call to [URL="http://cplusplus.com/reference/clibrary/cstdio/rewind.html"]rewind(infile)[/URL]. | |
Re: For the purpose of adding a one dimensional array works well enough in representing a matrix. For more complicated operations though, it would likely be easier to define a matrix like [ICODE]int mat[rows][cols];[/ICODE] | |
My program is getting hung up somewhere in the function [ICODE]evolveRealization[/ICODE] and while it is stuck its memory usage is increasing by around 1MB per second! While it is building up generations, it was designed to only use the most recent one, and the old ones should be freed. So … | |
I had forgotten about calloc for the longest time, but I was recently reminded of it. Now i'm curious, what would be the difference between [ICODE]malloc(numElems * elemSize);[/ICODE] and [ICODE]calloc(numElems, elemSize);[/ICODE]? If my knowledge of arrays is correct, there shouldn't be any difference in the memory allocated. | |
Re: The first parameter, hWnd (passed NULL) is the window to associate the new process with (NULL means you aren't using this feature). The second, lpOperation, is what you want to do with the file specified in the next parameter. Here we are "open"ing it. Speaking of which, the third is … | |
Re: [ICODE]char stu_name[10];[/ICODE] is defining just one string that can hold 9 characters. You should define it like [ICODE]char stu_names[10][NAME_LENGTH];[/ICODE]. And no, you should never add [ICODE]system("pause");[/ICODE] | |
Re: Well since this is a PHP forum, i'll give you a PHP solution. You could pass the css file for the iframe to use in the url like so: [CODE=PHP]<iframe id="pframe" width="'.$game['iframewidth'].'" height="'.($game['iframeheight'] + 20).'" src="'.$path.'?style='.$style.'" frameborder="0" scrolling="no" align="middle"></iframe>[/CODE] where style is the css file. In the iframe page, get … | |
Re: As soon as I looked at the code, the ugly [ICODE]void main[/ICODE] was staring me in the face. Please fix it in your code, so I can rest easier. | |
Re: Strings (if you do it the C way) should have a null character ('\0') to show where the end of the string is. Change your definitions to look like this: [CODE=C++] char username[15] = {'r','g','f','i','r','e','f','l','y','2','4','\0'}; // or char *username = "rgfirefly24"; //automatically adds the '\0' [/CODE] | |
Re: Read up on [URL="http://msdn.microsoft.com/en-us/library/bb775493(VS.85).aspx"]common controls[/URL]. | |
Re: You can't [I]define[/I] variables in the for loop header, so you need to put [ICODE]int i;[/ICODE] somewhere else. | |
Re: O(N...whatever) is [URL="http://en.wikipedia.org/wiki/Big_O_notation"]Big O Notation[/URL]. It is a way of expressing the efficiency (often the "worst case" efficiency) of an algorithm based on the size of its input. O(N) is a linear efficiency, other common ones are O(N^2) and O(log(N)). Note that coefficients are not expressed; you would not say … | |
Re: Yeah, that's really not a wonderful idea. Why don't you base your web blog on a database, and use a C++ program to connect to the database and add a new post that way? Your method depends way too much on hoping that everything will go as planned (window will … | |
Re: Since this is for a game (high performance required) I would recommend you look at [URL="http://msdn.microsoft.com/en-us/library/ms879875.aspx"]DirectDraw[/URL]. A decent tutorial I know is here: [URL="http://www.falloutsoftware.com/tutorials/dd/dd1.htm"]www.falloutsoftware.com[/URL] | |
Re: That would be a great plan if you were trying to write bad-looking and terribly inflexible code. You can do this with a loop, however, which will let you find the maximum of any amount of numbers you want. You should keep a variable holding the value that is the … | |
Re: Take a look at [URL="http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx"]ShellExecute[/URL] Edit: I misunderstood ArkM's post, I thought it was advising against the use of system() (as is usually the case). I suppose in this case, it would be okay? | |
Re: Does your page try to run the .exe to generate the new page? Byethost disables the running of executables for some pretty important security reasons. | |
Re: Think about array indices. To write them from beginning to end, you would start at 0 and go to arrayLength - 1. How might you do the opposite? | |
Re: A good way to implement this is giving each subcategory a reference (field) to the parent category's unique ID. You can do this with an auto-incrementing int field. A root category can just have the parent -1 (for example) to specify that it is at the top level. | |
Re: What is your problem? Compile errors? Your node class seems a little off to me also. What are the other pointers supposed to be for? Most linked lists only have pointers to the next and/or previous item (see [URL="http://en.wikipedia.org/wiki/Linked_list"]http://en.wikipedia.org/wiki/Linked_list[/URL]) | |
Re: Take a look at the [URL="http://aspell.net/"]aspell[/URL] dictionary. | |
Re: This thread was about connecting to Access, not MySQL. ODBC allows you to connect to databases with a level of abstraction over the specific database you use, letting you not have to worry about individual APIs. | |
Re: [QUOTE=jaanu.cheruvu]Our binary search[/QUOTE] Does this mean that you have one implementation already? Try posting it so we can see what it is you need to modify. | |
Re: A better idea, why not just include edge checking code when you count the neighbors? An if statement or two with a simple little condition(s). That way you don't have to start your array at index '1', therefore making it much simpler (especially to someone reading your code, ie. teacher). | |
Re: Try looking at [URL="http://hudzilla.org/phpwiki/index.php?title=Advanced_text_searching"]this page[/URL]. | |
Re: You never initialized the value of x. When is the loop supposed to stop? Stopping at the null character '\0' might be a good idea... Also, you can't have both the loop and and function keeping track of top. You can use a while loop to go through the string … | |
Re: Honestly, you have been given the proper solutions. Sending (and therefore, reading) your forms with the POST method sends variables through the headers sent. For this purpose, however, I would recommend SESSIONs as people could potentially look at the header information. SESSION variables are contained solely on the server (aside … | |
Re: While this is not critical in any way, you should note that the large outputting section at the bottom won't actually print any of the embedded quotes. In this line: [CODE=c++]cout<<"Each ""generation"" eight babies are born with variations." << endl; [/CODE] You are actually writing separated strings but the compiler … | |
Re: Just out of curiosity, does this mean that scripts are loaded into the PHP interpreter in their entirety, so that anything can happen to the file during execution and the its execution will be unaffected? | |
Re: I would assume you know how to create forms already. Have the login button send an AJAX request (by calling some JS in the onClick event handler) to a separate PHP login script (passing the username and password) which checks the database, updates session variables, etc. This file can respond … | |
Re: What about this: [CODE=C]double n = 123.456; int x = (int)(n + .5);[/CODE] If the decimal portion is .5 or greater, the addition will carry it up to the next higher integer. I would think it would be quite a bit faster. | |
Re: When AncientDragon wrote [ICODE]Code[h] != 0[/ICODE], his code was correct. Yours isn't. Why? AncientDragon's [ICODE]codes[/ICODE] array was a string literal, which automatically has a '\0' or 0 value at the end. Your array does not. Either append a '\0' element or change your codes array to look like AncientDragon's. | |
Re: Yep, [URL="http://w3schools.com/ajax/"]Ajax[/URL]. Its amazing how often this is asked in the PHP forum, maybe there should be a sticky... | |
Re: I do not know of any standard function that would perform this task. You could always fix your own code though. Do you understand what you wrote? [CODE=c++]int main (int argc, char *argv[], char **env) { char c, lastc = ' ' ; c = cin.get(); do { cout.put(c); c … | |
Re: Instead of making us download your .zip file, post some sample lines of the .dat file, including ones that do work and ones that don't (ie. Truman). | |
Re: Be careful to note that in math.h, these functions expect the angle in radians, not degrees. | |
Re: My best guess, without seeing this in context, is that it is to define a two-dimensional array. It is very unlikely that you will see pointers to single ints (unless you're trying to pass them by reference the 'C' way). In this case, you have one large array with lots … | |
Re: Replace "persons.txt" with a string variable containing the filename you have gotten from the user. I hope you know how to get user input... By the way, code tags should look like this: [code=c++] ...your code... [/code] The fact that you tried is appreciated, however :P | |
Re: I hope that you at least recognize the importance of the programming concepts rather than memorizing the text of the book, like your neurotic teacher seems to think. | |
Re: For me, this problem only occurred when I entered more than 100 characters. Try adding this: [CODE=cpp] if(cin.fail()) cin.ignore(256, '\n'); [/CODE] just after you read the filename. Other things wrong with your code: -Don't use system commands. Just don't. -You are letting the user input 20,000 characters into a 2,000 … | |
Re: So you want to provide a common portal to all three sites within your own? Use [URL="http://us.php.net/manual/en/function.fsockopen.php"]Sockets[/URL] to connect to their servers, get the page you want (while sending the info they require), and process it for the info you want. | |
Re: Well, does the Clients table have a field named propID? |
The End.