1,608 Posted Topics

Member Avatar for Bemani_lover

line 22 second program has out of bounds index used for S. If S has 4 elements, then the largest valid index is 3, as index values are zero based, meaning the first valid index is zero. S probably could be a 2 dimensional array, like this: double S[4][4]; rather …

Member Avatar for VernonDozier
1
167
Member Avatar for NordCoder

You may need more debugging statements. In general you need to post more descriptive narratives than "it doesn't work". When running the .exe version does the screen show at all? If the screen shows in exe version then what do you see when running in debug mode that you don't …

Member Avatar for NordCoder
-1
2K
Member Avatar for Vani3863

Does it compile? Does it run? Does it perform and behave like you would expect? If so, good job! Your posting skills could be improved, though. Look at the anouncements or get a bright light to read the water marks in the message box used to post code. They talk …

Member Avatar for Tom Gunn
0
2K
Member Avatar for tkud

The best thing to do is get a reference book, preferably hardcopy, though there are some online resources as well. In general you use filestream objects to read and write to files as opposed to an istream object (cin) and on ostream object(cout) to write to the screen. Once you …

Member Avatar for dkalita
0
194
Member Avatar for gemgirl1972

>>I was guessing they need to be string and 4 ints data type. That would be a description of the member variables needed for a class such as you describe.

Member Avatar for dkalita
0
203
Member Avatar for sfurlow

First, don't use void as return type for main(), even if your compiler allows you to do it. The return type of main() should always be int. Second, if you're at index i and there are three letters in the word, what would be the next index after the third …

Member Avatar for siddhant3s
0
94
Member Avatar for power_computer

To my knowledge you can't specify what to inherit and what not. You either inherit the whole shebang or you don't inherit anything. I always am receptive to being shown wrong, and thereby learn in the process, however.

Member Avatar for mrnutty
0
142
Member Avatar for xxunknown321

Declare a maze that will consist a 12 by 12 board represented internally by a 2D char array. The characters in the array will be # to indicate walls, space char to indicate available choices (unvisited cells) and * to indicate that we've been here before and can't go there …

Member Avatar for Lerner
0
202
Member Avatar for hectex

Post relevant trial input. You may just need to use an ostream manipulator to keep it displayed in the format you want.

Member Avatar for Lerner
0
346
Member Avatar for sivapc

char * add[200]; The above declares an array of 200 char *'s. Drop the * from the above to get a variable that will hold a string with up to 199 char plus the null char. The call to getline would be: cin.getline(add, 199); Actually, I forget whether the second …

Member Avatar for Lerner
0
189
Member Avatar for Wolf CCMLG

Well, it should be y = day; but I've been guilty of that typo more than once. I would:[code] //declare these variables within the class static const int daysInMonth[12] = {31, 28, 31, 30, //etc static const string monthNames[12] = {"January", "February", //etc int y; string dayString; //within the constructor …

Member Avatar for Lerner
0
1K
Member Avatar for truviet911

Since this is your second post to the forum I will assume you have read the announcements at the top to the board which indicate that you aren't to expect we do homework for you. Post a specific question with relevant code, error messages, etc.

Member Avatar for VernonDozier
0
97
Member Avatar for XodoX

Place lines 21 through 87 in a loop to allow for repetitive inputs. Use cin to pause the program to await for further input or for viewing. Is your board loaded correctly? Don't you need 8 unique pairs of numbers (1-8)? Your code just puts 16 numbers, each 1-8 in …

Member Avatar for XodoX
0
126
Member Avatar for vortex24

Make the filename a variable and then allow the user to input some or all of the variables data. Then pass that variable to the open() method or the constructor of the pertinent file stream. Note that arguments for filestream variables need to be a C style string, not an …

Member Avatar for Lerner
0
133
Member Avatar for sohaib770

There is no need that I know of. There is an option, just like there is with any function, whether it is overloaded or not. I don't think that having one function with default parameter and one with same argument that isn't default will count as overloading as the compiler …

Member Avatar for Lerner
0
71
Member Avatar for thisisanfield.1

Don't use the return value of eof() in controlling the loop. Sooner or later that syntax will result in creating a second copy of the last entry in the file. I haven't found a very readable explanation of why, so I don't post references. I recommend doing something like this:[code] …

Member Avatar for thisisanfield.1
0
141
Member Avatar for r4rozen

Please post your attempt with questions, pertinent error messages, etc. Start with a bare bones Hello World type program that has two variables and the ability to output the value of those variable. then accept user input into one of the variables and be able to output the input. Then …

Member Avatar for code zombie
0
94
Member Avatar for yonghc

This: string arrcon[5][35]; is basically a table of words/strings composed of 5 lines and 35 words/strings per line. The size of each word/string is indefinite. arrcon[1] is the second line of 35 words/strings, not a single word/string or a pointer to a string. scon is a pointer to a single …

Member Avatar for yonghc
0
411
Member Avatar for suutukil

Given an array called arr with n elements where x and y are indexes of individual elements in the array. Use a nested loop to compare elements of arr as follows:[code] outer loop controls x, x varies from zero to less than n -1 inner loop controls y, y varies …

Member Avatar for suutukil
0
623
Member Avatar for serdengil

I've never seen sequential dot operators used like this: myClass a; a.enter().push(); but I like learning new things, so if someone can confirm line two above as valid syntax assuming enter() and push() are valid methods for a myClass object, I'll be wiser than I am now.

Member Avatar for Lerner
0
122
Member Avatar for ticktock

>>I'd have to make functions or cases for each and every conversion like one for cm-m, cm-ft, etc. Is there any other way to do this? Sometimes the buttons can be used for different purposes depending on the state of the button or combination of buttons pushed or sequence of …

Member Avatar for ticktock
0
142
Member Avatar for Oritm

In C++ there are multiple varieties of strings. C style strings are null terminated char arrays. dateStr and timeStr in post #4 are probably going to be used as null terminated char arrays. Null terminated char arrays cannot be concatenated using the + sign. They must be concatenated using strcat(), …

Member Avatar for Lerner
0
140
Member Avatar for JETFUSION

Declare and define functions before calling them. As your directions instruct don't even try wirting inviteOrNot() until you have the other 3 functions up and running.

Member Avatar for Salem
0
144
Member Avatar for niyasc

Restricting yourself to C++ using standard methods and standard libraries to maintain portability restricts graphics capability. Conversely, doing something with graphics in C++ beyond simple static "ASCII art" restricts portability. To my knowledge at least, you basically have to accept one or the other restrictions if you want to use …

Member Avatar for mrnutty
0
193
Member Avatar for Covinus

Some compilers permit nonstandard syntax when it comes to declaring main(), but that's not the same as saying int main() isn't the standard or that it's standard to use void main() or just plain main(). If you want your code to compile on as many compilers as possible then you …

Member Avatar for Tom Gunn
1
1K
Member Avatar for power_computer

Go back to post #19. Add the lines in red to your original code and add another debugging line after this one: lCount = lCount - 1; that looks like this; cout << "lCount = " << lCount << endl; Recompile and run. Observe the power of debugging statements (if …

Member Avatar for emirpp
0
789
Member Avatar for valleymorning

Here's a rough protocol that will probably work: Accept input as a sequence of 6 digits in a string. Convert input string into a numerical value and save it. Separate input string into two separate strings based on given criteria. Convert each of the two strings into numerical values. Perform …

Member Avatar for John A
0
155
Member Avatar for ankit894u

What do you know about stacks? Do you have to write your own code for a useable stack or are you allowed to use prewritten code like the Standard Template Library version of stacks? Do you know how to write loops? Do you know how to obtain and assign data? …

Member Avatar for ankit894u
0
197
Member Avatar for lancevo3

LNode<T>* ptr; The above line doesn't give ptr a value. Therefore it could be anything. It could be NULL. It could be Oxeff34. It could be 99. Who knows. The problem is you check to see if it is NULL in the very next line. if(ptr == NULL) Before you …

Member Avatar for Lerner
0
87
Member Avatar for bond000007

Do you mean something like a functional "Hello World" project, a solution to a random Rubik's Cube using the fewest possible moves, or someplace in between those levels of difficulty? Without knowing what you can, or want to, do, it is almost impossible to recommend a "good" project.

Member Avatar for serkan sendur
0
192
Member Avatar for ryancfc

Assuming maxrand is an int, or something that equates to an int, then the number returned by rand % maxrand should be between zero and maxrand - 1, inclusive. It will never generate maxrand per se'. If you want between 1 and maxrand then add one to the above int. …

Member Avatar for ryancfc
0
174
Member Avatar for shea279

Nobody here knows what you mean by higher-level C++ programming classes. If you have a pretty good grasp of basic C++ topics such as pointers, arrays, loops, functions, classes, inheritance, file handling, etc, and you feel reasonable comfortable with STL classes, then you have the luxury of deciding whether want …

Member Avatar for John A
0
271
Member Avatar for jarrax

Google C++ RTTI to see if that's what you are thinking about or to give you some possible leads. Otherwise you might be able to embed class type information in a state variable of the base class so the type can be determined when using a base class pointer.

Member Avatar for Lerner
0
92
Member Avatar for vedybird

Here's an algorhithm in C/C++. You can convert it into whatever you're using. [code] int sec = 0; int min = 0; int hour = 0; while(1) { sleep(1000); //delay in milliseconds ++sec; if(sec == 60) { sec = 0; ++min; if(min == 60) { min = 0; ++hour; if(hour …

Member Avatar for mrnutty
0
130
Member Avatar for mandofl

I've never seen structs/class objects initialized using the {} syntax. To my knowledge that only works with arrays, though someone may prove I'm wrong on that. You can, and should, use the initialization operator with an overloaded, non-default constructor to accomplish the same purpose. The last snippet in post 3 …

Member Avatar for mandofl
1
7K
Member Avatar for Yaserk88

You can use the stringstream to convert the string to any valid numerical type, as long as the variable you are reading into is in scope. As long as you know the makeup of the file you can use control statements/loops to determine how many in each line to convert …

Member Avatar for Lerner
0
108
Member Avatar for lancevo3

char *strcat( char *str1, const char *str2 ); That's the prototype for strcat() from the online reference I usually refer to. I always thought str1 needed to be a null terminated char array and str2 needed to be either a null terminated char array or a string literal. I am …

Member Avatar for lancevo3
0
156
Member Avatar for abby2589
Re: OOP

As currently written you will be able to handle one customers account per run of the program. While that might be an appropriate initial step in the assignment, I presume that the final assignment will require that the user be able to enter more than one customer information per run …

Member Avatar for Lerner
0
105
Member Avatar for walter clark
Member Avatar for TheSwagger

What's wrong with the way you did it (other than it should be: while(oper != 'X');)? I think the flow of the program could be improved, but terminating without using exit() looks okay. You could use a bool variable if you want, but the concept remains basicly the same.

Member Avatar for TheSwagger
0
65
Member Avatar for lancevo3

Without listing the first few errors you receive it's not possible to say with surety what you have going. However, the object you have used called this is a pointer and rightOp is apparently a C styled string. As such you can't derefernce a C styled string. What you probable …

Member Avatar for lancevo3
0
339
Member Avatar for theashman88

How about using a sentinnel/flag? A little bit of a hassle to enter an additional keystroke, but it is completely portable, offers complete control without using magical combinations, etc.[code] bool moreInput = true; char temp; while(moreInput) { //get input cout << "enter y to keep going, anything else to stop" …

Member Avatar for tux4life
0
247
Member Avatar for samm22

The first one looks like a declaration of a vector of ints of size alpha, if alpha is an int---or something that acts like an int. The second parameter to the constructor has the default value. I have no idea what the second is attempting to do. Wild guesses might …

Member Avatar for samm22
0
87
Member Avatar for chrishtones
Member Avatar for Chargers 21

First, please learn how to use code tags when posting to this board. See the announcements at the top to board to learn how to do this. Second, rand() in this line: if (guess != rand()) should be randNum. Third, I think it would be better with a while loop …

Member Avatar for Lerner
0
121
Member Avatar for ivanhuk

>>I have no choice but to create the arrays in my class dynamically since he wants a destructor included. That's really two different conditions. This: Question::~Question() {} is a valid destructor implementation assuming no dynamic memory is allocated for object variables or someplace within an object method (that isn't deleted …

Member Avatar for Lerner
0
145
Member Avatar for joed13k1941

I probably has to do with the functionality of cin.fail(). Change your loop to something different. Maybe something like this;[code] bool more = true; char flag; while(more) { cin >> n; //do dah cout << "do you want to enter another value. Enter y for yes and n for no" …

Member Avatar for collegetextbook
0
304
Member Avatar for BretFelix

You haven't indicated what feature you are going to sort on. Will it be the whole line or will you sort based on a given field within the line. That is will you sort by the firstName field or by the studentNumber or by one of the other fields? If …

Member Avatar for MosaicFuneral
0
2K
Member Avatar for Sushma21

>>can we access text files randomly Short answer, no. Well, probably not. Depends on how the file is written. Er, I don't think so. Since each object in the file contains an array of possibly indeterminant/nonstandard length, then the number of bytes of memory required for each objects' information storage …

Member Avatar for Sushma21
0
122
Member Avatar for SP IT

The End.