Forum: C++ 33 Days Ago |
| Replies: 17 Views: 600 You should check where the program crashes, and read the error message(s).
Check your arguments closely - what's being used here, and what is being used without having a value assigned?
... |
Forum: C++ Oct 17th, 2009 |
| Replies: 4 Views: 221 I think a better approach would be just use getline to grab all of a line into a large string, then print out the first 22 characters that appear (or less if the line's not that long.)
You can... |
Forum: C++ Oct 14th, 2009 |
| Replies: 5 Views: 608 What I believe the problem is asking you to do is set up the 2D array.
Read in the temperatures along the edges (is the temperature the same all along an edge or does it vary along the edge,... |
Forum: C++ Oct 12th, 2009 |
| Replies: 6 Views: 643 I'll write that code for $25,000
How low can the bidding go?
Maybe this should move to Geeks' Lounge? |
Forum: C++ Oct 10th, 2009 |
| Replies: 5 Views: 366 A little searching effort on your part will get results much faster than just shouting out questions to the world.
Try this (http://lmgtfy.com/?q=differences+are+between+c+%26+c%2B%2B) |
Forum: C++ Oct 10th, 2009 |
| Replies: 6 Views: 498 Your smaller code compiled fine in VC++ 2008 Express, once I commented out the #include "stdafx.h".
Similarly, commenting out stdafx.h and a couple other minor changes to allow compiling as... |
Forum: C++ Oct 10th, 2009 |
| Replies: 1 Views: 148 for the general search function, take the else return -1 out of the for loop. That return statement should only execute if you complete the for loop and don't find the search value.
int ary[]... |
Forum: C++ Oct 9th, 2009 |
| Replies: 5 Views: 188 Well think of how you would do things if you had a red ball in your right hand, a green ball in your left. What steps would get the balls to be in the opposite hands? Keeping in mind, you can have... |
Forum: C++ Oct 6th, 2009 |
| Replies: 2 Views: 273 Your second version is really not going to work - your swap portion only changes the assignment of the temporary pointers in the function, it does not change the ->next pointers in the actual nodes. ... |
Forum: C++ Oct 3rd, 2009 |
| Replies: 2 Views: 257 for (i=1; i<=value; i++)
{
cout << "Enter some values: ";
while (cin >> value)
cin >> counter[i];
sum+= counter[i];
}
middle = sum / value; |
Forum: C++ Sep 20th, 2009 |
| Replies: 3 Views: 250 OK, you found the compile time error.
Now, there's still a potentially fatal logical error to be corrected. |
Forum: C++ Sep 14th, 2009 |
| Replies: 1 Views: 185 look here (http://lmgtfy.com/?q=cause+effect+analysis) |
Forum: C++ Sep 13th, 2009 |
| Replies: 4 Views: 244 when passing the row from a 2D array to a function that takes a 1D parameter, use only the row index in your argument.
foo( test[0] );
That essentially passes a pointer to where that row... |
Forum: C++ Sep 7th, 2009 |
| Replies: 4 Views: 226 "Hello world", of course. It's the law! |
Forum: C++ Sep 2nd, 2009 |
| Replies: 23 Views: 1,009 You're on the right track, but not really moving all the songs following the deleted item up. You only move the i+1 element to the i postion when the match was found. Everything past that will... |
Forum: C++ Aug 29th, 2009 |
| Replies: 9 Views: 450 If the code above is in a loop, where you ask for a new word to seek, your problem is that the file is left pointing past its end.
Unless you do
dict.close( );
dict.clear( );
before you... |
Forum: C++ Aug 24th, 2009 |
| Replies: 12 Views: 750 OK, how about this (http://www.softpedia.com/progDownload/Microsoft-Visual-C-Toolkit-Download-11595.html)? |
Forum: C++ Aug 24th, 2009 |
| Replies: 7 Views: 273 Declaring the array as you're trying to do, you MUST declare the sizes of the row and column dimensions*.
To allow the user to enter the size at runtime, you'll have to use dynamically allocated... |
Forum: C++ Aug 8th, 2009 |
| Replies: 9 Views: 296 (rand()%4)+1 can only give you values from 1 to 4, so you're going to have duplicates, possibly several of the same.
To get unique values, at each assignment you have to examine the previously... |
Forum: C++ May 22nd, 2009 |
| Replies: 12 Views: 1,035 And for your future reference, when you have an if...else if block that is separating values into range groupings, you don't need to test both upper and lower bounds in the succeeding conditions.
... |
Forum: C++ May 22nd, 2009 |
| Replies: 12 Views: 1,035 Instead of the big if...else if block, how about
for( int i = 0; i < 10; i++ )
{
index = arr[i] / 10;
str[index] += "*";
} |
Forum: C++ May 20th, 2009 |
| Replies: 6 Views: 341 Imagine you have it all drawn out on paper - the locations of customers and the potential store sites. How would you solve it manually? Approach it from a strictly procedural method - don't assume... |
Forum: C++ May 17th, 2009 |
| Replies: 7 Views: 429 It looks like you're close to having a working program.
Have you tried compiling? If so, you'd find that you have two errors. One is a missing #include and the other is a small typo. Find and... |
Forum: C++ May 8th, 2009 |
| Replies: 3 Views: 211 Your first line creates an array of int pointers.
The p[i] line allocates memory to each of those pointers, in effect created an 2-dimensional array of ints. So, each p[i] is the name of a single... |
Forum: C++ Apr 25th, 2009 |
| Replies: 14 Views: 907 Well, some mod you are! Don't you see the sticky thread at the top about books? :icon_razz:
A good many of the first shown when you search Amazon look like good prospects, like #4 - C++ for... |
Forum: C++ Apr 24th, 2009 |
| Replies: 4 Views: 301 We don't do homework for free.
We help you to fix and to understand the work you do. |
Forum: C++ Apr 9th, 2009 |
| Replies: 7 Views: 626 When a cin >> is followed by getline( ), you will need to use the ignore( ) function in between. You normally don't need the ignore( ) between two input statements of the same type. |
Forum: C++ Apr 8th, 2009 |
| Replies: 7 Views: 496 How about this in your row function?
while(e!=8)
{
Possible[f]=Possible[f+1];
f++;
}
What would cause that loop to ever end? And you have a similar problem in the column function.
... |
Forum: C++ Apr 6th, 2009 |
| Replies: 20 Views: 884 Your second post looks like you're trying to do Bubble sort. You have the comparison and the exchange OK, it's the looping that's lacking.
Look in your textbook, or do a quick internet search and... |
Forum: C++ Mar 15th, 2009 |
| Replies: 4 Views: 260 My crystal ball needs new batteries, so I really don't know what you're trying to do, or what your assignment is asking you to do.
Just looking at this bit of code, each of the three functions are... |
Forum: C++ Mar 10th, 2009 |
| Replies: 11 Views: 1,112 foo2( ) will also give the size of the pointer, not the array. |
Forum: C++ Mar 8th, 2009 |
| Replies: 7 Views: 938 Bevox
You are passing a pointer by value, but the function will be manipulating the memory pointed to by the pointer. So yes, our function can change that memory allocated and owned by main,... |
Forum: C++ Mar 7th, 2009 |
| Replies: 7 Views: 419 cout<<reelArray[i]<<' '<<reelArray[i]<<' '<<reelArray[i]<<endl;
You're telling it to display the same thing three times!
reel1 = 1 + rand()%(max - 1 + 1);//RNG 1 through 7
Why the adding... |
Forum: C++ Mar 6th, 2009 |
| Replies: 8 Views: 744 Two questions.
Is the file data in ascending order?
What is that for loop inside the first if of your binary search supposed to be doing? If you found that array[middle] is the value you seek,... |
Forum: C++ Mar 4th, 2009 |
| Replies: 7 Views: 327 A couple other comments.
By declaring the strings in global space, they get set to all 0's. When you reverse the string, you get a valid string because there are NULL terminators in the... |
Forum: C++ Mar 4th, 2009 |
| Replies: 2 Views: 429 The compiler is aligning the struct elements on word (4byte) boundaries, thus the two empty bytes between your char's and the next element.
You might look up what the pack pragma will do for you,... |
Forum: C++ Feb 9th, 2009 |
| Replies: 6 Views: 1,696 Sure this is working right?
how about while( temp[i] != NULL )
temp itself will never be NULL in this usage. |
Forum: C++ Jan 28th, 2009 |
| Replies: 9 Views: 408 Ohhhh, that hurts!
You should put all that tedious code into a loop, so you have only one line that calculates the dev, then displays it. Actually, you can do all of that in just one line - do... |
Forum: C++ Jan 18th, 2009 |
| Replies: 5 Views: 440 Function prototype:
int loadArray(const string[][2]);
Function definition:
int loadArray(string secArray[][2])
Not the same signatures!
Do you really need/want the const qualifier in the... |
Forum: C++ Nov 23rd, 2008 |
| Replies: 6 Views: 415 If you're referring to your array Items, then you've got to use the strcpy( ) function to copy from one index (a row of your 2D array) to another.
This line
if ((choice != 1) && (choice !=... |