1,608 Posted Topics

Member Avatar for Himerz

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 …

Member Avatar for zalezog
0
140
Member Avatar for minime2100

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 …

Member Avatar for minime2100
0
94
Member Avatar for tones1986

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 …

Member Avatar for Murtan
0
160
Member Avatar for obsy

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 …

Member Avatar for obsy
0
102
Member Avatar for Linking_90

>>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. …

Member Avatar for Linking_90
0
145
Member Avatar for nitu_thakkar

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?

Member Avatar for Narue
0
83
Member Avatar for Emerald214

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 …

Member Avatar for Emerald214
0
147
Member Avatar for rickster11
Member Avatar for sarifah

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 …

Member Avatar for sarifah
0
112
Member Avatar for moshe5

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 …

Member Avatar for Lerner
0
115
Member Avatar for Stefano Mtangoo

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 …

Member Avatar for Stefano Mtangoo
0
86
Member Avatar for StandardsDT

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 …

Member Avatar for StandardsDT
0
152
Member Avatar for Mike Savino

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.

Member Avatar for kbshibukumar
0
71
Member Avatar for atman

//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 …

Member Avatar for Lerner
0
126
Member Avatar for kotkata

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 …

Member Avatar for Lerner
0
103
Member Avatar for kiong

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 …

Member Avatar for Lerner
0
99
Member Avatar for Passiongamer25

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 …

Member Avatar for Passiongamer25
0
180
Member Avatar for Stefano Mtangoo

[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 …

Member Avatar for Stefano Mtangoo
0
150
Member Avatar for soroushc

>>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 …

Member Avatar for Stefano Mtangoo
0
168
Member Avatar for christiangirl

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 …

Member Avatar for Lerner
0
121
Member Avatar for soroushc

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 …

Member Avatar for VernonDozier
0
111
Member Avatar for peacerosetx

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 …

Member Avatar for Lerner
0
186
Member Avatar for rickster11

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 …

Member Avatar for ShawnCplus
0
185
Member Avatar for Phil++

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 …

Member Avatar for StuXYZ
0
112
Member Avatar for smashpumpkin

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 …

Member Avatar for smashpumpkin
0
122
Member Avatar for maddy05

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 …

Member Avatar for Murtan
0
246
Member Avatar for oblivion4

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.

Member Avatar for oblivion4
0
125
Member Avatar for anuroop0707

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 …

Member Avatar for Lerner
0
254
Member Avatar for jorgeberber

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 …

Member Avatar for Lerner
0
168
Member Avatar for 35nando

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.

Member Avatar for 35nando
0
2K
Member Avatar for vandenzergen

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 …

Member Avatar for vandenzergen
0
116
Member Avatar for cam875
Member Avatar for cam875
0
110
Member Avatar for Clockowl

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 …

Member Avatar for Lerner
0
459
Member Avatar for nrupparikh

Depends on the circumstances. Here's one way. ofstream.fout("DesiredNameOfFileToCreate.txt");

Member Avatar for William Hemsworth
0
68
Member Avatar for athar89

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 …

Member Avatar for Murtan
0
185
Member Avatar for manzoor

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 …

Member Avatar for Salem
0
202
Member Avatar for orwell84
Re: GUI?

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 …

Member Avatar for orwell84
0
207
Member Avatar for fedderico10

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());

Member Avatar for Lerner
0
171
Member Avatar for boomtoom

>>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 …

Member Avatar for cikara21
0
160
Member Avatar for mrboolf

I'd put the deal protocol in the game section as not all card games are dealt the same way.

Member Avatar for Murtan
1
527
Member Avatar for jimbob90

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 …

Member Avatar for ArkM
0
289
Member Avatar for Onizukas

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)

Member Avatar for Lerner
0
78
Member Avatar for Yuichi

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 …

Member Avatar for Yuichi
0
181
Member Avatar for serkan sendur

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 …

Member Avatar for serkan sendur
0
2K
Member Avatar for stindeee

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 …

Member Avatar for Lerner
0
91
Member Avatar for ninja_gs

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?

Member Avatar for Freaky_Chris
0
109
Member Avatar for shadwickman

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.

Member Avatar for shadwickman
0
115
Member Avatar for mmeyer49

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 …

Member Avatar for Lerner
0
149
Member Avatar for cerb63

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.

Member Avatar for tarakant_sethy
0
149
Member Avatar for gamer12223

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 …

Member Avatar for Murtan
0
162

The End.