- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 10
- Posts with Upvotes
- 9
- Upvoting Members
- 10
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
46 Posted Topics
Re: I'm still in college and I've made some simple games like tetris and pacman and currently working on a super mario 2D sidescroller variant, but not very large games, so I'm still a bit above a beginner when it comes to game development. I recommend you use C/C++ for game … | |
Re: You don't need the iomanip header file. It just allows you to format your code nicely. So to make the above code work, just remove functions like `setw(number_here)` and it should compile. | |
Re: It's advisable not to use file.eof() because the stream only signals EOF when it reaches the very end of the file. So if there's an empty line or if there's extra whitespace at the very last element, the stream still considers data to be read. For example, inputData.txt ---------------------- 1 … | |
Re: The instructions to compile is at the very top: Compiler: mpicc -g -Wall -o name name.c mpirun -np 4 name mpicc is the compiler -g -Wall are additional options to pass to the compiler -o name is the output executable file called "name" name.c is the name of your source … | |
Re: It seems the compiler is looking for the definition of the int main() function but it can't find it, but you want to make a DLL. The problem is you're compiling the code as an application (.exe) instead of a dynamic library (.dll). Go to project properties -> General -> … | |
Re: I suggest you reading about keyboard accelerators here on MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646337%28v=vs.85%29.aspx Keyboard accelerators is an easier way to handle combinations of keystrokss like Ctrl+Z or Ctrl+C You define the accelerators in your resource file, assign a hotkey and give it a unique name. // In your code, declare a handle … | |
Re: Library files (.lib) are usually stored in a folder called lib. First you add the path to the search directory, so the compiler knows where the library files are. But you have to tell the compiler which library file (.lib) to link to. For example, a lib folder could have … | |
Re: The variable ReadSect is given a proper value. Lines 12 and 13 become 0 << 9 and 0 >> 23 which both equal 0. | |
Re: If you have multiple MAX macros, the compiler has to reserve memory for each occurence. ie. MAX + MAX - MAX is 3 substitutions of integer 5, so 4\*3=12 bytes reserved If you declare a constant, it's only declared and initialized once in memory, so it takes up only 4 … | |
Re: I think you mean "pass by reference" and not by value. Anyways, I recommend reading this about input/ouput with files here http://cplusplus.com/doc/tutorial/files/ You should also list an example of the file you're talking about. | |
Re: Swap lines 35 and 36. | |
Re: Try printing to standard output instead. Perhaps the input data is not being read properly? You can also check if the input and output file is open with is_open() member function. | |
Re: You can read about input/output with files here http://cplusplus.com/doc/tutorial/files/ In order to store/read information from a file you have to create an object that represents the file. This is an example of storing data in a file. The great thing about file objects is that it's treated as a file … | |
Re: The logic of your Bike class is completely wrong. When you pedal x amount of meters, you should add that to distance. Then when you want to get the distance travelled so far, you're simply return 0. Return 'distance' instead. You also have to use boolean variables to check if … | |
Re: Hmm, are you allowed to nest a function within a function? Like you have in your everyNth() function with the nested numDigits() function? Another thing is you cannot declare a static array with a variable. On line 23 you declared `int array[numLength]` which is not allowed. You must use a … | |
Re: Where's the `int main()` entry function? You have to include the constructor for your class under public. Where's the code for the functions in your Envelope class? You either didn't include the code or you didn't write them. | |
Re: You should use Visual Studio to debug through program and see where the problem is. The debugger will know if you're trying to access memory that doesn't belong to your program. Or you can always use printf() statements to see which ones output or not to debug the program. Segmentation … | |
Re: You should clear out the `WNDCLASS wc` structure to empty with this: `ZeroMemory(&wcex, sizeof(WNDCLASSEX));` Try using `ShowWindow(hWnd, SW_SHOW)` with SW_SHOW as a second argument. | |
Re: You are able to change the sampling state any time you wish. Because you're modifying the filters for textures that are minified (opposite of magnified), you should see the difference of the texture from a distance. You can try using the same texture of the same size drawn far away … | |
Re: You're right, that is the proper behaviour. If an error occurs on input operations, subsequent input operations will fail to work. So I'm guessing an error occurs when you just enter "hello" with no space. Check for error/EOF flags with fail() or eof() methods. For example, char name[200]; cin.get(name, 200); … | |
Re: If you wanted to add two fractions together, you need two objects of class fraction. You should use a third object to store the result. You already have the formula, so implementing is quite easy. Just remember, your fraction class represents only "one" fraction, so use more than one and … | |
Re: It's not supposed to work like that. You have to create the font again, replacing the old one. So call CText::Create() with an italic parameter. | |
Re: Your scanf should be `scanf("%d,%d", &coef, °ree)` There is a logical error with your while loop condition. You say you want non-zero coefficients and any degree, but exit if both are zero? Correction: `while (coef == 0 || !(coef == 0 && degree == 0));` If coef == 0 just … | |
Re: Lines 309-315 (WordList.cpp) you have the following code but the variable 'indx' was never declared? And you have to make sure indx is not out of bounds which could cause the program to crash. If for example, indx exceeds CAPACITY. const void WordList::operator+=(string word) { if (indx < CAPACITY) { … | |
Re: You should struct/class declarations in your header file (.h) list.h struct list { node_t* head; }; typedef struct list list_t; Because when you rename the structure list to list_t but nowhere was struct list defined before that line. | |
Re: Header files can be quite confusing and with the inclusion of so many header files, it can be difficult to track the bug. A possible culprit is with main.h and CApplication.h **main.h** #include "CApplication.h [...] **CApplicationn.h** #include "main.h" [...] **CApplication.h** <--- expanded [substitute in main.h] [...] #pragma comment (lib, "d3d9.lib") … | |
Re: You should just put all the code that you're going to repeat under the while loop, instead of splitting it up. In fact, use a do loop which guarantees it always runs once. do { cout << "Average calculator." << endl; cout << endl; cout << " Enter a stream … | |
Re: > i dono y ur complicating too much just try this The question wants you to reverse the entire string then each word within the string. Example, Our string: "The sky is blue" Reverse the entire string: "eulb si yks ehT" Reverse each word in the string: "blue is sky … | |
Re: Think about what WaltP said. If the result is always zero, then none of the if statements are true. You never get a value greater than or equal to 70,000 or 50,000 or 30,000. | |
Re: You can compare strings with function strcmp(). For example int i; char* names[3] = { "john", "jessica", "james" }; char* findname = "jessica"; for (i=0; i<3; i++ ) { if (strcmp(names[i], findname) == 0) { printf("We found a match to %s at index %d", findname, i); } } | |
Re: This is not what you want: `sizeof(A/2)` You want `sizeof(A)/2` You can't divide the A by 2, that doesn't make sense, right? Move the 2 outside the brackets. | |
Re: I advise you to format your code so it's easier to read, because it's hard to help someone when the code is hard to read. The task is simple if you think about it in steps. 1. Open the file. 2. Read the number of patients first, the first line … | |
Re: Lines 298-303 (wordlist.cpp), in method `const void WordList::operator+=(string word)` just check if the indx is within range. // do we have space to add 1 more word? if (indx + 1 < CAPACITY) { setWord(indx, word); incWordCount(indx); incNumWords(); indx++; } Line 149 (p2.cpp) you have `void readFile(ifstream &filein, WordList WL)` … | |
Re: char sn[5] should be char sn[9] (4 more characters to fit '.txt' suffix) but yes fopen works, remember strings must be wrapped in double quotes "" like fopen("03/1234.txt", "r") | |
Re: It would be much easier if you posted the line on which the syntax error occured, if it is possible anyway. However, the problem I see is with line 99: in >>data[i].barcode >> data[i].prodname >> data[i].category >> data[i].price; The member variables 'prodname' and 'category' of type std::string but you're trying … | |
Re: Can you explain more about the problem? Like give an example. Sounds like your problem is math-related? System of equations like? I only have guesswork so you have to explain more. | |
Re: Clear error on line 81. You never passed anything to printResult(). It should be like printResult(integer_here, double_here, double_here, double_here). | |
Re: Proper indentation of lines makes it much easier to read, hard to tell if a piece of code executes inside the for loop or outside. But I can see what you're trying to do. Should look like this, with proper indentation using spaces and tabs: for (i = 1; i … | |
Re: If you're calling `student_Data.getAwardAmount();` you should store the return value in a variable as such and pass the variable to : `getScholarship_Money()` int number_of_awards = student_Data.getAwardAmount(); student_Data.getScholarship_Money(number_of_rewards); But first change this `getScholarship_Money(int getAwardAmount())` to `getScholarship_Money(int awards)` To your other question, you cannot return two or more values, you are only … | |
Re: Each string in 'arrayList' has to have enough space to store LETTERS+2 characters plus 1 for the null character if you're using strncpy(). So you have to declare 'arrayList' as `char arrayList[100][LETTERS+2+1];` or something similiar. Or perhaps your 'arrayList' doesn't have enough space, so you could be going past the … | |
Re: There are several problems with your code. A segmentation error most likely means you access a variable outside the range of an array of some sort, such as your scores or alphabet array. 1. The variable score (singular) is not declared. 2. The while loop should be an if statement … | |
Re: Can you run it through a debugger? You should try stepping through the code using a debugger. Otherwise, try using several printf() statements and see where it fails to print. There are a few things to note, when you write `mCard = new Card*[52];` (line 26) means you're declaring an … | |
Re: I think you have to specify the type T. Template functions, I believe, can only deduce what T is based on the arguments passed. The compiler does not know if you want to return an integer or float based on having std::string as an argument, for example. `int x = … | |
Re: I could see that you've tried sorting the grades in the for loop which appears to be like a bubble sort (google that) with all the swapping. Like Ancient Dragon said, there are many ways you can sort data, just search sorting algorithms and use whichever one you think you … | |
Re: I assume you're working with the Windows API which include types like LPSTR or UINT or LPTSTR. These are just normal types you're familiar with but given a different name to be used specifically on a windows machine. ie. UINT = unsigned int LPSTR = char\* LP stands for "Long … | |
Re: I believe it has to do with whether your project is a console versus a win32 app. You can check this in the project->properties under linker->system. The "system" must be Windows and NOT console. |
The End.