624 Posted Topics
| |
Re: Use a 2d array to represent the tic tac toe grid, not a seperate variable for each place >.< . And also...post the whole code. I don't understand why your calling wincond() at the start of main. It does literally nothing there. Also, never forget to initialize variables! Also, you … | |
Re: (x - a) ^ 2 + (y - b) ^ 2 = r ^ 2 Where a and b are the center coordinates, and r is the radius. This should help you solve for x, and y, given one or the other. This is useful for plotting, but sin, cos, … | |
Re: [QUOTE=bugmenot;730013]If I initialize graphics in my program and then use cout the font appears bigger than normal and the cursor doesn't blink on the screen as it does when the graphics are not initialized.Is there any way I can use graphics as well as cout in my program?If yes how … | |
Re: Do a google search on PCM wave format header information, then create a struct/class with all the neccessary members that the header contains, plus a dynamic array (vector perhaps) of actual raw wav data. You will then need to find an appropriate library/dll for interpreting the data and sending it … | |
I'm writing a class for simple equation parser. I've completed the - and + operators, and am currently working on implementing brackets. They seem to work most of the time, except I occassionally get strange results, such as with 10 - ((10 - 20) + (10 - 20)) returns 40! … ![]() | |
Re: Sounds like your trying to parse a function. You'll have to enter the function as a string (either char * or string class), then use a loop to figuire out its contents. Depending on how robust/useful you want it to be, this could be a bit challenging for a beginner. … | |
Re: Hmmm when you use sizeof(), I would sugguest using the structure name instead of the structure being loaded. For example, if the structure was called sDirection: [code=cplusplus] file1.read ( reinterpret_cast<char*>(&north), sizeof(sDirection) ); [/code] I'm not to sure of the technicalities behind why that causes problems, but I know I've had … | |
Re: kph should be a double. When you make consts, read the data type from right to left. const double kph_to_mph should be double const kph_to_mph. In your loop you are not really doing any calculating. Instead, you are displaying the initial value of kph * kph_to_mph. Since kph is uninitialized … | |
Re: A tutorial isn't generally going to tell you how to make the program you want to make :P . Here's a simple prime function [code=cplusplus] bPrime = true; for (int ii(2); ii < _iVal / 2; ii++) { if (!(_iVal % ii)) { bPrime = false; break; } } [/code] … | |
Re: At a glance I saw more than 15 syntax errors. I'm way too lazy to point those all out... you have [] around a cout statement - that would probably make a compiler explode. You have ; all over the place where they shouldnt be. You have a few instances … | |
Re: [B]--what exactly does a parameter do? i know it passes a value to a function-but how is it always like that? or is it more complicated than that? is it kind of like passing a power in math?[/B] Im not sure what you mean by 'is it always like that'. … | |
Re: You will need to look up the wav class implementation and headers assosciated with it. Different forms of wav (although not that many) require different headers. PCM is most common, so google WAV PCM C++. Then you can do a binary dump from the wave to the wav class members, … | |
Re: remember that an array's max index is always 1 less than its size, since 0 is included. So for part 1, numberArray[0][0] = 148; and #2 numberArray [8][10] = 18; | |
Re: C++ can be a bit overwhelming to teach yourself. There's a lot of very specific syntaxes that you have got to get comfortable with first. I taught myself qbasic inside and out when I was about 12, which helps me immensely with c++, even though the languages are completely different. … | |
Re: Yikes. It's too hard to help you because I am totally unfamiliar with that particular chips op codes. And I'm not familiar with that header file either. Generally these forums are for windows/linux programmers. Does this need to be written in C++? Because if it can be written in assembly, … | |
Re: For problems like this, I would step through the code (via F10 to step through and F11 to step 'in' in VC++). Keep an eye on your local variable list, and as their values change make sure that they are changing as expected. If not, you can isolate the exact … | |
Re: Do it in a loop [code=cplusplus] for(int i(0); i < SIZE_OF_ARRAY; ++i) array1[i] = array2[i]; [/code] | |
I'm interested in writing a memory scanning program (for cheating in games, looking for hidden processes, and such). I'm wondering if there's any way to do this with C++ without extensive knowledge of windows classes/programming. I'm thinking assigning a pointer to the first location of the processes stack or something, … | |
Re: I would sugguest the vector class, since it does all the finicky dma for you. Use it like this: [code=cplusplus] #include <vector> #include <iostream> #include <algorithm> using namespace std; class flyer { char * _szType; int _iPriority; public: char * _szName; //add flyer data here (flight time? etc) //im not … | |
Re: Think of arrays as pointers to the start of a stream of data. When comparing them, you are comparing the memory address of the first value of the array with the second. These will never be the same, unless one array references another. Basically it's a redundant test that shouldn't … | |
Re: I imagine an ini file could be loaded from the same way any txt file could be loaded from, can it not? Although I bet there's probably some useful classes out there that have done the parsing for you. | |
Re: [code=cplusplus] int list::recursion(int item, int position, node * temp = startPtr) { if (temp->next) { if(temp->item != item) recursion(iItem, position + 1, temp->next); } else position = -1; //not found flag return position; } [/code] I'm not sure if this will compile, or even work properly (lol). I hate doing … | |
Re: Show some effort first please. Hint: To get an ideal hash index via modulus just do this: [code=cplusplus] int iIndex(x % MAX) [/code] where x is the value that your finding an index for, and MAX is the maximum index you want (ie the max size of the hash table … | |
Re: In some compilers (like VSC++) int is implied when only the const keyword is used (like you did). It is always safest to issue a datatype, however, since many compilers require it. | |
Re: It could be a hardware fault. Typical troubleshooting steps for this would include the following steps: 1. Reseating the current cd-rom drive to ensure it's not a simple connectivity issue. If this fails, 2. seating a known-working cd rom drive into the laptop to see if it works. If it … | |
Re: Ints usually take up 4 bytes of memory, while chars only take 1. You can always cast them into one another, but this can cause undesired results when converting from int to char - some bits may be truncated, or in some compilers could cause a conversion error. | |
Re: Hmmm Where exactly are you having the problems....? | |
Re: [QUOTE=jbrock31;723555]Hi everyone. I decided to try and learn C++ on my own and i have ran into a problem and i just need slight kick in the butt. :) I am just learning structures and i am practicing using some of the examples at the end of the chapter in … | |
Re: If you are using a c style null terminated string, you can cast them into an integer to display the ascii value, and just bias it however you feel. ie [code=cplusplus] int iUpperBias(64); //ascii for G(71) - 64 = 7 like you desire int iLowerBias(96) char * szString; //fill with … | |
Re: I'd recommend you either #ifdef #define something at the start of your .h file, or use a #pragma once line to ensure it isn't being included multiple times. | |
Re: Logical AND - &&, Logical OR - ||, Logical Inversion - ! Some things you should get comfortable with. | |
Re: This site's a good place to start. There's a whole tutorials section that you might find interesting. | |
Re: I don't understand why you have a inStream >> next; statement before your while loop... The reason why you are getting such strange results when inputting is that you are inputting data past the end of file (ie loading in 100 values when the file only contains 16). Instead of … | |
Re: Write a parsing program (something that splits a bigger data type ie. a ISBN number to a more manageable datatype ie. an array of char[]). Load in the ISBN number from the file, and make sure it doesn't contain more than 3 dashes (-), that it only contains numbers (other … | |
Re: [QUOTE=NinjaDude007;722844]I am gonna start off saying that I am new to C++, and I have little programming knowledge (just Q Basic, and it has been a while since I have used that), and I need help on an assignment in my C++ class. We have to use a case function … | |
Re: You can't really. The console isn't meant for that sort of shennanigans. You could make something horribly ugly (with a lot of effort) I suppose... | |
Re: Your exit method should work, although a more effective method is, after the cin >> invoiceNum line, have a check against EXIT_CODE, and if it does exist, use a break; command to leave the for loop, then it should jump out of the while loop as well. There's a few … | |
I'm not sure I did this right. It's for an assignment for school where i'm supposed to return the author last name and the balance (described below) relating to each author. It's from the pubs database (I'm thinking that most people have used it for testing/learning before?) I'm an SQL … | |
Re: The people there already gave you pretty good advice. It's a program that does nothing, perhaps a header file? It requires libraries that aren't included with vb, so a direct translation isn't really feasible. | |
Re: Hmmm. Maybe you should include the code to make the program run? Also, I would sugguest using inheritance rather than unions for this (like ancient dragon said). Here's the drawer header my school usually uses, which is also our model for learning inheritance, as it demonstrates it quite nicely (as … | |
Re: That's the fifth time you've been asked to use code tags. I'm not going to help you anymore. I explained their syntax 4 times! | |
Re: The x/100 is an integer divide. So when 456 is divided by 100 = 4.56. Since it's an integer, the decimals (non-integer) are truncated (removed), so the first part of the cout (x/100) displays 4. Then the modulus operator divides x by ten and returns the remainder. 456 / 10 … | |
Re: Im not sure I understand the problem. What is search supposed to be returning? True if the value a is found? Are you unsure what to put in the if statements? Please be more specific. I compiled your code and found it to be pretty broken in other places. I … | |
Re: I don't understand your function. It seems as though in the cout line, that getstock is recursively (and endlessly) calling itself. It doesn't even return any value that could be displayed if the recursion wasn't endless! I think you are meaning to call some sort of string from a member … | |
Re: Please use code tags. This is the third time I have warned you about this. People generally feel less inclined to help if they have to spend triple the time understanding the scopes of the program and finding un-highlighted keywords. Again, the syntax is [ code = cplusplus ] code … | |
Re: When you leverage off of the = operator without an overloaded ooperator=() implemented, the compiler uses a predefined method of copying the data by doing a direct member to member copy. Since you are using pointers as members, the addresses of the pointers are being copied, rather than firing the … | |
Re: Hmm please use code tags. And what was the actual question? Please post the specific part of your code that you are having issues with. |
The End.