Forum: C++ 1 Day Ago |
| Replies: 5 Views: 153 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 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 Views: 143 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 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 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 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 Views: 179 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 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 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 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 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 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 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 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 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 Hard time converting radians to angles? |
Forum: C++ Jul 9th, 2009 |
| Replies: 52 Views: 1,438 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 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 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 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 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 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 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 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 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 Views: 427 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 Views: 1,243 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 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 |
Forum: C++ Feb 5th, 2009 |
| Replies: 3 Views: 439 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 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 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 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 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 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 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 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 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 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 >>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... |