279 Posted Topics
Re: Is this really what you want? [icode]#include "enum.cpp"[/icode] | |
Re: The usual approach here is to "shuffle" the numbers and then pick them off one by one. (Code untested.) [code] // Load array for (int i = 0; i < 40; ++i) n[i] = i + 1; // Shuffle for (int i = 39; i > 0; --i) { // … | |
Re: You haven't said what's actually happening. What is it doing wrong? Is there any error messages? | |
Re: Isn't a pbm a text file? Shouldn't you be writing your numbers as text, with: [icode]writer << img_pix[i].rgbb[0];[/icode] | |
Re: [icode](int)log10(n) + 1[/icode] will give you the number of digits. You could strip digits off with a loop body like this: [code] digit = n % 10; // store digit or whatever n /= 10; [/code] | |
Re: It's possible a malicious program is (imperfectly) hiding itself. | |
Re: Try this: [code] struct RGB { GLubyte r, g, b; }; RGB **bufImg; bufImg = new RGB*[height]; for (int i = 0; i < width; ++i) bufImg[i] = new RGB[width]; [/code] | |
Re: This is you eighth post and still no code tags??? | |
Re: Not all COM methods return an HRESULT although most do. For the ones that don't, the object documentation should tell you what to check for to detect an error condition. With a BSTR return, it should be NULL on error (since it's a pointer). | |
Re: And don't post a program with half the lines commented out. Remove them first to clean things up a little. | |
Re: By "exit code" NicAx64 meant the code that the program returns to the OS. Try writing a simple program that produces a file over 2GB and see if that works. Write OVER 2,147,483,648 (2GB) bytes. Compile it identically to your problem program. Does it work? | |
Re: In this case, perhaps IDE means Interactive Drawing Environment! IDE usually means "Integrated Development Environment," such as Visual-C++. | |
Re: Rename your [b]memset[/b] function so it doesn't have the same name as the library function. I don't know about the problem with [b]printstr[/b]. | |
Re: He's using a special header. You do not want the semicolon at the end of the parenthesized portion of the if statement. Other than that, it seems weird to be assigning y and z a constant value and then testing whether or not either are zero, which is what your … | |
Re: You need to use the [icode]/c[/icode] option on cmd: [icode]psexec \\a19-00 cmd /c 'start www.google.com'[/icode] | |
Re: You need to test string[count] != 0 in your while condition. You need to increment count in your loop or you never look past the first character in string. You probably want strchr, not strpbrk, and you won't want to simply assign it's return value to string[count]. strchr will return … | |
Re: Try something like this: [code] typedef int Data; typedef queue<Data> Queue; vector<Queue> v; for (int i = 0; i < nQueues; ++i) v.push_back (Queue()); for (int i = 0; i < nQueues; ++i) for (int j = 0; j < 5; ++j) // some data v[i].push (j); [/code] | |
Re: Similar to the other program, this bit is faulty: [code] if((ptr=fopen("hello.txt","r"))!=NULL) { while(!feof(ptr)) { fstring[i++]=getc(ptr); } } [/code] Try something like this: [code] if((ptr=fopen("hello.txt","r"))==NULL) { printf("can't open file\n"); return -1; } int c; while((c = getc(ptr)) != EOF) fstring[i++]=c; [/code] | |
Re: This puts one extra character at the end. [code] while(!feof(ptr)) { org[i]=getc(ptr); printf("%c",org[i]); i++; count++; } org[i]='\0'; [/code] Instread, try this: [code] int c, i = 0; while ((c = getc(ptr)) != EOF) org[i++] = c; count = i; [/code] Also, try using the [b]isupper()[/b] and/or [b]islower()[/b] functions for the … | |
Re: It's a matter of where you want to store the object, and whether you wish it to remain in existence after the function in which it was created has returned. What you are calling "static" allocation (more properly "automatic") saves the data on the stack. Dynamic allocation stores the data … | |
Re: Could you do something like this: [code] scanf( " " ); // Consume whitespace, if any (incl. newline) fgets( ... ); [/code] | |
Re: If you need any doubles, they would be [b]cents[/b] and [b]total[/b]. You only need one loop, with an integer index counting the days. Take another stab at it and think it through step by step. | |
Re: You need to show your compiler and link commands. | |
Re: In class TextField, [b]lines[/b] needs to be a [icode]Field**[/icode] And in [b]TextField::TextField[/b], line 5 should be [icode]lines = new Field*[num];[/icode] | |
Re: Try passing back by value (not reference) from operator=. | |
Re: You need to declare the operationType in menu as a reference. 86 the asterisks. Remove one tab from the beginning of every line. | |
Re: Also, organize your data into structs (if you are able/allowed). | |
Re: You're supposed to use code tags when posting code. You'll need to show what you've attempted so far. | |
Re: The first step in a project is knowing what you want, and being able to explain it to others is a measure of that. However, with this thread and your previous thread I'm beginning to see what you mean. You wish to simulate a CPU memory cache with a 64-bit … | |
Re: Try defining the argument variables (that you are setting in the if stmts and passing to the functions) at the top of the file, making them global: [code] int arg1; int argArr1[22]; //... [/code] This is not usually a good design, but if you are just trying to get it … | |
Re: You've forgotten the [ ] around the array size in the initializer of p. Thus you are declaring p to point to a single double of value n. As you attempt to read memory past this first value you eventually get a segfault. However, if you fix that problem, another … | |
Re: I'm not sure what you mean. What do you mean by "memory addresses and times for stores"? What memory addresses? What stores? What times? What loads? | |
Re: MyStudent.Name is the name of a storage location capable of holding up to 20 characters (including the terminating null character). You cannot simply assign a string constant to MyStudent.Name since that just tries to copy the [b]address[/b] of the string constant to MyStudent.Name. What you need to do is copy … | |
Re: Sleep a day at a time. Check the date/time every time you wake up. | |
Re: Have you tried [url=http://www.winprog.org/tutorial/]theForger[/url]? Also note that [url=http://msdn.microsoft.com/en-us/library/default.aspx]MSDN[/url] (Microsoft Developer Network) has full windows documentation and a [url=http://msdn.microsoft.com/en-us/library/aa383668(VS.85).aspx]generic sample application[/url] as well as a [url=http://msdn.microsoft.com/en-us/library/aa383686(VS.85).aspx]categorized list[/url] of API (Application Programmer Interface) functions. There is also [url=http://msdn.microsoft.com/en-us/library/d06h2x6e.aspx]MFC[/url] (Microsoft Foundation Classes), an object-oriented wrapper for the API, but you should probably learn … | |
Re: When you swap elements in the salesID array, swao the corresponding elements in the other arrays. | |
Re: This deactivates the close option. Remember that you'll have to catch ctrl-C too. [code=cpp] #define _WIN32_WINNT 0x0500 #include <windows.h> int main() { HWND hwnd = GetConsoleWindow(); HMENU hmenu = GetSystemMenu (hwnd, FALSE); HINSTANCE hinstance = (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE); while (DeleteMenu (hmenu, 0, MF_BYPOSITION)) ; system ("pause"); } [/code] | |
Re: In C++ this problem would usually be solved using a [b]string[/b] and a [b]map[/b]. Is there any reason you're not using these? If you must use strtok and do not want to copy the tokens it finds but instead just point to them like you are trying to do, you … | |
Re: Even though you store it in a double, you are still doing integer division because both operands to the slash are integers. Add a decimal point to at least one of them to get decimals. [icode]value = 1.0 / 2;[/icode] | |
Re: Start by reading the code you've been given carefully and try to understand it (it would be too tedious to explain it here; consult your textbook). Then write a piece of the implementation (e.g., initialize the cave) and test it. Then write the next piece. Note that the cave is … | |
Re: In the standard "16.2 Source file inclusion" (my first reference!) it mentions an interesting difference between <header.h> and "header.h". Basically, it says that the "" form may not even be supported, and if it isn't or if it is but the file is not found using that method, then it … | |
Re: A first post homework dump. Try filling in the functions a little. | |
Re: Try moving your definition of [icode]flight schedule[][/icode] to the beginning of main. | |
Re: You haven't initialized the local variables you use in main. | |
Re: It might look harder than it is. Here's an explanation of the first one: [code] Input: n Start r at 0. Loop n times (using index from 0 to n-1): * when index is less than n/2: add 1 to r (this is done n/2 times) * when index is … | |
Re: You probably shouldn't be "going to main". Remove the [icode]return main();[/icode] part and change it to a loop. | |
Re: Narue, can you really dynamically allocate a [b]static[/b] array in C99? Just seems odd. Is it only sized on the first call in your example? | |
Re: Here's a function that uses a set to remove duplicates from a vector without changing the order of elements: [code] void remove_dups (vector<string>& v) { set<string> s; pair<set<string>::iterator, bool> result; for (vector<string>::iterator i = v.begin(); i < v.end(); ++i) { result = s.insert(*i); if (!result.second) { v.erase(i); --i; // adjust … | |
Re: You're mixing C-strings and the C++ [b]string[/b] class. Here you just want plaing old C-strings, which do not have member functions associated with them, so you can't do the substr thing. Just do it in a normal old C way. |
The End.