1,608 Posted Topics
Re: No compiler to use at the moment so here's some things you can try doing to see if you can figure out why your code isn't working, assuming you don't want to follow iamthwee's suggestion. 1) be sure there's enough room in letters for the null terminator. Either try increasing … | |
Re: Or, if you prefer and are allowed, since you include the string header file you can change the declaration of name to type string like this: string name; rather thn using C style strings as you have done. Some of the advantages of the string class as opposed to using … | |
Re: Stacks can be based on a variety of other data structures, of which lists are one possibility. Since I don't feel like wading through 9 files of code to answer the question for your specific purposes my response will be a template for a plan to create a stack to … | |
Re: You have lots of choices. niek_e has given the outline of one way. Others would include. 1) Identify the file to read. This may be as simple as the file name and extension if the file is in the same directory as the exe of the program or it may … | |
Re: >>is word has N digits[only digits] and each digit in the word is in increasing order example 1469 or 362 First, should that be 236 instead of 362? Second, what if word is a string rather than an int? When I think of word I think of string, not int. … | |
Re: Are you thinking about using the () as the conversion operator or talking about overloading the () operator to do something like addition or concatenation or some other theoretical possibility? | |
Re: how much memory does the following take? const int a[]; answer: I don't think it is defined. In fact, if declared outside of class that line wouldn't compile because the size of the array needs to be known at compile time, like it is in main(). I'm not sure why … | |
Re: They are mathematical operators. Add one to the value of current variable and store the new value in current variable. Subtract one from current value of variable and store new value in current variable. Multiple the current variable value with the right hand side of the operator and store the … | |
Re: Here's another angle. Declare another array to hold the answer. I called it answerArray surprisingly enough. Use it as the left hand side of the following line: copyArray[x][y] = recursive(copyArray, x, y); and use it to display the answer. Then set copyArray to originalArray each time you test a new … | |
Re: In classes everything is declared private by default. You have to explicitly use the keywords public or protected, and it's fine to explicitly use the keyword private as well.[code] #include <iostream> using namespace std; class Math { private: //this line can be removed without detriment to the program, but there … | |
Re: Your code looks okay other than the lack of indentation. After 113 posts to the board I would have hoped you'd have learned how to preserve those details when posting code to this board by enclosing code in code tags as disscussed in the announcements and in the watermarks of … | |
Re: How is stuAns declared? If it is a char array, like this: char stuAns[10]; or a string like this: string stuAns; or a vector like this: vector<char> stuAns; then "A" and "B" should be 'A' and 'B'. If that's not it, then I'd request you post more code. | |
Re: //create object called a mkdef: 1 La-de-da:1 12 //create object called one mknew: 2 La-de-da:2 //destroy object called two when closing } in foo() found rm: 2 //create object called b mknew: 7 Bye..Bye... //find closing } for main() so destroy objects still in scope //object b destroyed first since … | |
Re: cout << name << " " << age << endl; in that line cout should probably be changed to out. ________________________________________ >> I keep getting this error for the Pet read function: no match for 'operator>>' in 'fin >> You need to include the fstream header file if you want … | |
Re: Not sure why printf() or c_str() are needed, but ..... I'd create an array of alllowed strings and use a loop to search the array, displaying appropriate statement if equality identified. I'd break out of loop if input channel found and review value of counter/index when loop done to determine … | |
Re: Remember that each variable needs to be given a default value before you try to output it or use it in a calculation. Also remember that each element of an array is a unique variable. Therefore, each element of an array needs to be given some default value before you … | |
Re: [code]int myfunc(int, int); //function prototype int main() { myfunc(6, 6); } int myfunc(int x, int y) //function definition { if(x == y) cout << "Yeah"; else cout << "Boo"; }[/code] The function prototype is almost the same as the first line of the function definition. The differences are the prototype … | |
Re: >>I know how to use strings. To use STL strings you need to include the header file called string. To read a string that has whitespace in it, such as the following: name | 12.2 23.3 343.2 | you need to use getline(), not >>; as >> stops input into … | |
Re: Try to be more specific in your description of your problem. If you say you are supposed to alternate popping the elements of each queue until both queues are empt displaying them to the screen as you go if the char in the file is an asterisk, then I'd expand … | |
Re: Looks like English isn't your native language. Unforturnately, that means it is difficult for me to understand what you are trying to do. getline() will accept input from the keyboard (or other source) and store it in a string variable. It has nothing to do with how the value of … | |
Re: const ap::real_1d_array& x----this appears to be a constant reference variable called x of type real_1d_array. real_1d_array is apprarently a user declared type in the ap namespace. Being a constant reference means that the value of x cannot be changed in this function. This type (user declared type) is probably an … | |
Re: if (degreeType != 'c' || degreeType !='f') How can degreeType be both 'c' and 'f' at the same time? It can't obviously, so the above statement will always resolve to true. Therefore, you always get the error message followed by the output of degreeType on line 23 followed by the … | |
Re: Unfortunately not all strings are equivalent, and not all string routines work with all strings. As a general rule I wouldn't use both C style I/O and C++ style I/O in the same program as it can lead to unintended behaviours. That means I would recommend thinking long and hard … | |
Re: you need to initialize each element of occuarnces to zero before you try to increment them. I suspect you want to loop through list to see if the word was found before and if not then add it to the array.[code] for each word in list if current word equals … | |
Re: Well, I don't see a function called issue(). I do see a function called issuebook(). Is that the one you are refering to? While waiting for reply I offer the following in terms of general recommendations. 1) Don't use void as the return type of main(), even if your compiler … | |
Re: Yes. TCHAR tword[10] = TEXT("WORLD"); Instead of the TEXT macro used above you could also use L"WORLD" or _T("WORLD"). At least they worked when I ran up against this hurdle. | |
Re: The first thing you need is to gather the right tools. In this case can you view the CSV file that you will be reading from by opening it in Notepad so you know that it is intact? Do you know how to open/create a file? Do you know the … | |
Re: I assume you mean you want to add the price of each item identified within the loop to a variable representing a "subtotal" that has been declared before the loop and given the value of zero before the loop (either by initialization or by assignment). If not, try to be … | |
Re: Hint: google search using C++ matrix determinant. It provided 12,000 hits. One of them, probably early on in the list, probably/may have something to help. | |
Re: You start with a dream and go from there. Some people prefer to jump off the high dive into deep water and learn how to swim or die trying. Others take the more sensible route and start from the beginning before getting in over their heads. I'd suggest the latter … | |
Re: LogicMolecules(index) Use square brackets rather than () in the above. | |
Re: do a Google search using phrase, OpenGL tutorial. Then select tutorial at NeHe.com. They instruct you to use a Win32 project, not a console project, and they included these headers in their initial project: #include <windows.h> // Header File For Windows #include <gl\gl.h>// Header File For The OpenGL32 Library #include … | |
Re: Depends on the circumstances. Here's one way. ofstream.fout("DesiredNameOfFileToCreate.txt"); | |
Re: Use int as the return type for main(). Even if your compiler lets you use void as the return type, it's better to use int. Try to figure out where the problem is by commenting out all but the most basic part of the program. In addition to compiling, be … | |
Re: 1) You could sort a copy of the array to determine the values and then search the original array for the desired values. 2) You could place the first n values of the array in a list using and insertion sort so the head of the list is the smallest … | |
Re: These days the console is a window with specific, default restrictions. That being said, to port code written for a console to a window requires you to know functions that are specific for any given GUI. Simply put, there is no simple tansition that I know of. Sure, the concept … | |
Re: You can store the return value in a new variable and pass it to the use the second function or you can place the function call from the first function inside the parameter list of the second. int temp = classA.function1(); classB.function3(temp); classB.function3(classA.function1()); | |
Re: >>i thought some one here could help me They could, and usually will. But, the above statement implies effort on your part, which has yet to be demonstrated. Most people who respond to posts here aren't willing to do the project for you. Do what you can, then post a … | |
Re: I'd put the deal protocol in the game section as not all card games are dealt the same way. | |
Re: You can either: 1) declare object of type tvShow and use the dot operator (if you use static memory to declare the object) or the arrow operator (if you use dynamic memory) to access the member variables that you need to fill in the blanks. 2) you could declare and … | |
Re: look up stringstream. In particular you can create a stringstream from the input sentence and then "read the sentence word by word" by writing it to a holding string using the >> operator to parse the input by whitespace char (the space and newline chars in your case) | |
Re: Do you use the >> or any other input method in the program? Whenever you use more than one input method in a program you need to be aware of the status of the input buffer before each input. It looks like you attempted to input the maze line by … | |
Re: cin >> bookrec.info_title; getline(cin, authorName); Narue's answer covers it all, but it isn't immediately obvious (at least to me) that it does so. Unfortunately I don't know a straightforward answer, so I'll offer another "explanation" instead. Here goes. You can get into problems if you mix input methods (>> and … | |
Re: Please put your code snippets into a program, compile and run. I think you'll find that your code doesn't generate the pictures that you want. Do you realize you can make a diamond picture with 2 triangles instead of 4? Conceptually it seems easier to do with 2 than with … | |
Re: How are the char stored---individual free standing variables, string (C style vs STL string object vs other string object implementation like CString or APSTring), or individual char in an array/list/vector/stack, whatever? | |
Re: Works for me too. I keep getting the same shuffle of the deck because I didn't seed the random number generator before calling rand(), but I have had no problems with erasure of element from vector using either VC6++ or VC8Express. | |
Re: It will make your life easier if you explicitly specify the number of rows in addition to the number of columns in your array. In your display function this won't work: cout << (char){201,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,187},....... You need to output elements of an array one at a time, with the one exception … | |
Re: pA and pB are both pointers to objects, not objects per se. Therefore use the arrow operatos to acess the data members, not the dot operator. | |
Re: TMoney money[3]; money[0].inputData(); money[0].outputData(); If you have an array but only use the first element of the array, why bother with the array. I'd use a loop in main() to access all three elements of the array, calling input() on each of them in turn and calling output() only if … |
The End.