Search Results

Showing results 1 to 40 of 94
Search took 0.02 seconds.
Search: Posts Made By: Lerner ; Forum: C++ and child forums
Forum: C++ 1 Day Ago
Replies: 5
Views: 153
Posted By Lerner
You didn't call binarySearch() in post #1 so it wasn't needed. I just assumed you didn't post showArray() because it wasn't pertinent. I just added a definition for showArray() with empty function...
Forum: C++ 1 Day Ago
Replies: 5
Views: 177
Posted By Lerner
What is sizeof(e) anyway given that name can have any size up to 79? If you wanted to use write() I would recommend using two separate calls, one using strlen(eArray[counter].name) as the second...
Forum: C++ 2 Days Ago
Replies: 3
Solved: Output Line
Views: 143
Posted By Lerner
Frist, main() should return type int, not type void. Even if your compiler allows you do use reurn type void, don't do it.

The problem you allude to however, probably has to do with line 118. If...
Forum: C++ 2 Days Ago
Replies: 5
Views: 182
Posted By Lerner
To my knowledge, only if wheels is a member variable declared with keyword const. That is, it is the declaraion the member variable called wheels as const that prevents it from being changed somehow...
Forum: C++ 2 Days Ago
Replies: 1
Views: 132
Posted By Lerner
First, welcome to the board. Then not necessarily in order of importance:
1) Your syntax is more C than C++. You might get better response posting on the C board section of this site rather than...
Forum: C++ 4 Days Ago
Replies: 3
Views: 130
Posted By Lerner
I still don't understand the question. Please be more specific.

I do see that you don't null terminate can->name in putCandy() so technically can->name is a simple char array not a string. Try...
Forum: C++ 6 Days Ago
Replies: 2
Solved: Arrary help 2
Views: 179
Posted By Lerner
I assume food and calories are parallel arrays meaning that food[x] has calories[x] calories and you want to keep the food matched with the correct calories and you are trying to alphabetize the food...
Forum: C++ 13 Days Ago
Replies: 12
Views: 476
Posted By Lerner
Build on what you know. For example here's a progression you might be able to use.

Write code to read the whole file one line at a time and display the line to the screen.

Modify the above...
Forum: C++ Oct 27th, 2009
Replies: 5
Views: 251
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: 211
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: 306
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: 293
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: 585
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: 513
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: 465
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: 867
Posted By Lerner
Hard time converting radians to angles?
Forum: C++ Jul 9th, 2009
Replies: 52
Views: 1,438
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: 504
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,682
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: 196
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: 1,051
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: 401
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: 910
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: 338
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,661
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: 427
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,243
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: 296
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: 443
Posted By Lerner
Try namefield[0] = '\0';
Forum: C++ Feb 5th, 2009
Replies: 3
Solved: Queue problem
Views: 439
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: 245
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: 344
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: 1,002
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: 771
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,378
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: 416
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: 847
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,284
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: 1,042
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: 763
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...
Showing results 1 to 40 of 94

 


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

©2003 - 2009 DaniWeb® LLC