Search Results

Showing results 1 to 40 of 100
Search took 0.02 seconds.
Search: Posts Made By: Lerner
Forum: C++ 33 Days Ago
Replies: 5
Views: 226
Posted By Lerner
purposely over commented code for beginner to understand process
//declare a flag variable
bool invalidInput;

//outer loop controls number of digits input
while(k < MAX_DIGITS)
{
//reset...
Forum: C++ Oct 12th, 2009
Replies: 2
Views: 198
Posted By Lerner
Please learn how to use code tags when posting code to this board. It is a bit of a hassle, but given it preserves the spacing you (should be) use in writing the code it is well worth it. There are...
Forum: C++ Oct 9th, 2009
Replies: 6
Views: 291
Posted By Lerner
have you tried syntax similar to this:

MyObject.bvec[n];

It should work as long as n is less than the size of bvec, which in the code provided would anything 0-9 inclusive.
Forum: C++ Oct 4th, 2009
Replies: 8
Views: 281
Posted By Lerner
I would insert each term in terms in ascending order based on the exponent so that the exp term with exponent 0 has index 0 in terms, etc. I would expand terms if the exponent of a term to be added...
Forum: C++ Sep 29th, 2009
Replies: 2
Views: 501
Posted By Lerner
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...
Forum: C++ Sep 16th, 2009
Replies: 7
Views: 486
Posted By Lerner
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...
Forum: C++ Jul 13th, 2009
Replies: 10
Views: 453
Posted By Lerner
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...
Forum: C++ Jul 9th, 2009
Replies: 13
Views: 844
Posted By Lerner
Hard time converting radians to angles?
Forum: C++ Jul 9th, 2009
Replies: 52
Views: 1,392
Posted By Lerner
I am certainly no expert in STL, but it is my understanding that the const char * embedded in the STL string class isn't necessarily implemented as a C style string----that is, it isn't necessarily a...
Forum: C++ Jun 27th, 2009
Replies: 3
Views: 497
Posted By Lerner
This: while(in.eof()!= 1)
is probably why it is always shows the last object read in twice. You shouldn't use the return value of eof() to control performance of a loop body for that very reason....
Forum: C++ Jun 5th, 2009
Replies: 28
Views: 1,666
Posted By Lerner
Option 5, Delete Marks.
Once you have stored information in an array you can't delete it. There, plain and simple. Having said that you can create functionality to make the program act as though...
Forum: C++ May 26th, 2009
Replies: 5
Views: 193
Posted By Lerner
You have mixed use of >> and getline() in the same program. If you do that you need to be aware that >> will leave the terminating char in the input buffer which will be evaluted when the next call...
Forum: C++ May 22nd, 2009
Replies: 12
Views: 999
Posted By Lerner
Another approach might be to display as you go. Here's some pseudocode to rough out how that might work:

1) declare variables needed---stream to read file and two int variables
2) use a while...
Forum: C++ Apr 16th, 2009
Replies: 3
Views: 396
Posted By Lerner
getseat is to check that user input is valid:
set flag to true
while invalid row number
ask user for row number of seat they want
accept user input
if user input is valid
change flag...
Forum: C++ Apr 9th, 2009
Replies: 12
Views: 868
Posted By Lerner
Use a loop to count down:
cout <<"The program will be terminated in ";
for(int i = 5; i > 0; --i)
{
i << " seconds..." << endl;
Sleep(1000);
}
Forum: C++ Apr 6th, 2009
Replies: 5
Views: 332
Posted By Lerner
Start at the beginning. You know user will not be able to enter more than 20 numbers, but you don't know exactly how many until run time. One approach is to declare memory for 20 possible numbers...
Forum: C++ Apr 2nd, 2009
Replies: 5
Views: 2,503
Posted By Lerner
play around with the value of n and see what happens. In particular, try changing n from 1 to 2 to 3 etc. The function as written isn't specific for rounding to 2 decimal places.

Also, look into...
Forum: C++ Mar 30th, 2009
Replies: 4
Solved: linked list
Views: 423
Posted By Lerner
I find your problem description difficult to read/decifer. I would start by putting the following lines:

cout << "num is " << num << endl;
cin.get();

between these two lines:

inFile >>...
Forum: C++ Mar 30th, 2009
Replies: 9
Solved: C++ instanceof
Views: 1,143
Posted By Lerner
Since you are storing pointer to type objects why not try using polymorhism by writing a base method called displayPay() declared with the keyword virtual that would be overloaded with in each of the...
Forum: C++ Mar 6th, 2009
Replies: 5
Views: 291
Posted By Lerner
else
{
if (seats[position]==0)
cout<<"You have booked "<<position<<".Thank you\n";
seats[position]=1; //to change the array from 0 to 1
}

In addition, pay a little more...
Forum: C++ Feb 19th, 2009
Replies: 2
Views: 421
Posted By Lerner
Try namefield[0] = '\0';
Forum: C++ Feb 5th, 2009
Replies: 3
Solved: Queue problem
Views: 427
Posted By Lerner
addToQueue() adds a single char to the queue with each function call but I don't think it is optimal for queue inplementation, meaning it will be difficult to keep track of which element has been in...
Forum: C++ Feb 3rd, 2009
Replies: 3
Views: 244
Posted By Lerner
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...
Forum: C++ Jan 30th, 2009
Replies: 9
Views: 338
Posted By Lerner
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...
Forum: C++ Dec 11th, 2008
Replies: 17
Views: 989
Posted By Lerner
I'd put the deal protocol in the game section as not all card games are dealt the same way.
Forum: C++ Dec 9th, 2008
Replies: 10
Views: 767
Posted By Lerner
Assuming you have declared bookrec like this:

info bookrec;

Then using >> to input information into the member variables is an option. If none of the strings will contain embedded whitespace,...
Forum: C++ Nov 23rd, 2008
Replies: 4
Views: 2,319
Posted By Lerner
You have several options. Here's one:
char ** strings;
strings = new char* [501]; //display an array of 501 char pointers.
for(int i = 0; i < 501; ++i)
strings[i] = new char[41]; //each of...
Forum: C++ Nov 22nd, 2008
Replies: 6
Views: 412
Posted By Lerner
const int MAXSIZE = 4;
int mine[MAXSIZE] = {1, 2, 3, 4};
int actualSize = 4;
int target = 2;
int targetIndex = -1;
//goal, find the 2 and overwrite it by shifting the 3 and 4 to the left by one,...
Forum: C++ Nov 17th, 2008
Replies: 9
Views: 792
Posted By Lerner
put a semicolon after the closing bracket of the declaration of the struct and recompile.

More importantly, never, ever, write the whole program and then hit the compile button. You're asking for...
Forum: C++ Nov 16th, 2008
Replies: 6
Views: 1,238
Posted By Lerner
change array to be of type string, not type int.

to evaluate/scan/print an array backward start with the largest valid index used and decrement the index each time through the loop instead of...
Forum: C++ Nov 15th, 2008
Replies: 2
Views: 995
Posted By Lerner
Try placing a line like:

HINSTANCE Window::hInst;

and initialize it with a default value if possible like a good little variable outside the class; after the closing semicolon of the class...
Forum: C++ Nov 14th, 2008
Replies: 7
Views: 729
Posted By Lerner
>>Any solutions to this?

On the other hand, depending how you want to do things, do you even want to change the array values? You could make the change only if needed in a function. Say something...
Forum: C++ Nov 13th, 2008
Replies: 13
Solved: help with loops
Views: 765
Posted By Lerner
Where are the loops?

Here's one way to progress to the answer without jumping in head first:
Write a program that writes 4 As to a line using a loop.
Then write a program that writes 4 As to...
Forum: C++ Nov 11th, 2008
Replies: 4
Views: 396
Posted By Lerner
If you can successfully output the contents of the array before passing it to bubblesort, then within bubblesort() you could try outputting the array before trying to sort it to be sure it has been...
Forum: C++ Nov 2nd, 2008
Replies: 3
Views: 469
Posted By Lerner
you are starting temp at the beginning of the list each time through. I'd consider setting temp to the beginning of the list outside the function, then pass the item, the position and temp to the...
Forum: C++ Nov 1st, 2008
Replies: 2
Views: 493
Posted By Lerner
Another option would be to use a stringstream to parse the line once it's been read in using getline().
Forum: C++ Sep 26th, 2008
Replies: 8
Views: 648
Posted By Lerner
if dataMember is a string variable encapsulated in the object item, then yes, you could potentially use either node->item.dataMember or node->item->dataMember depending on whether item is on object...
Forum: C++ Sep 26th, 2008
Replies: 5
Views: 738
Posted By Lerner
Forget about writing code for now. Using pencil and paper figure out the relationship between the three classes and attributes of the three classes. Then try to write code. Often, if your...
Forum: C++ Aug 15th, 2008
Replies: 13
Views: 2,521
Posted By Lerner
This:
else
sum = 0;
sum = sum + A[number];}
is equivalent to this:
else
{
sum = 0;
}
sum = sum + A[number];}
Forum: C++ Aug 11th, 2008
Replies: 6
Views: 735
Posted By Lerner
>>can someone tell me how to make an asterisk frame using for loop statement in C++

Give it your best shot and post a specific question with code/error statements/etc as needed. This is a common...
Showing results 1 to 40 of 100

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC