Forum: C++ 30 Days Ago |
| Replies: 17 Views: 577 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++ 30 Days Ago |
| Replies: 2 Views: 201 What's the largest value that can be stored in a long int?
How does that limit compare to the value you're trying to stuff into a long int? |
Forum: C++ Oct 21st, 2009 |
| Replies: 3 Views: 514 To read just 5 characters at a time to your array, you could use getline( ).
Make your array size 6 to allow for the null terminator at the end of a string, then
char arr[6];
//open your... |
Forum: C++ Oct 17th, 2009 |
| Replies: 4 Views: 220 Yes, you could use a loop to print only up to 22 characters. Be sure to first test the length of the actual string content, and limit your loop to 22 or the string length, whichever is less. |
Forum: C++ Oct 17th, 2009 |
| Replies: 4 Views: 220 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 13th, 2009 |
| Replies: 3 Views: 268 Why are you doing two input actions in the loop?
The first, in the while condition, reads the word and stops at the newline. The getline will read and discard the newline, storing an empty string to... |
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: 488 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 3rd, 2009 |
| Replies: 5 Views: 451 Visual C++ (other than the free express editions) can compile 64bit directly in the IDE. It does appear that you can compile from the Express edition, using command line compilation. See here... |
Forum: C++ Sep 20th, 2009 |
| Replies: 3 Views: 249 OK, you found the compile time error.
Now, there's still a potentially fatal logical error to be corrected. |
Forum: C++ Sep 20th, 2009 |
| Replies: 2 Views: 263 In your count function, you have two basic approaches.
1 - Run through string 26 times, each time counting the occurrence of the corresponding letter. Keep track of the letter that has occurred... |
Forum: C++ Sep 7th, 2009 |
| Replies: 1 Views: 238 look at the various "find" functions that are part of the string class. |
Forum: C++ Sep 4th, 2009 |
| Replies: 2 Views: 163 You realize you're responding to an old response to an even older thread? Better to start your own, you can refer to the past discussion.
Here's what you should be seeing |
Forum: C++ Sep 4th, 2009 |
| Replies: 6 Views: 376 First look at the discussion in this thread (http://www.daniweb.com/forums/thread215615.html), which as of this writing is right below yours.
Then write some code, post it, and we'll go from there. |
Forum: C++ Sep 2nd, 2009 |
| Replies: 3 Views: 281 If they are member variables of the class, they are not global. They are, as you note, accessible to all functions of the class. However, they are accessible only within a given instance of the... |
Forum: C++ Aug 24th, 2009 |
| Replies: 12 Views: 747 OK, how about this (http://www.softpedia.com/progDownload/Microsoft-Visual-C-Toolkit-Download-11595.html)? |
Forum: C++ Aug 24th, 2009 |
| Replies: 12 Views: 747 Shoot, I thought I had the C++ link. I'll poke around some some more, they do hide it well. |
Forum: C++ Aug 24th, 2009 |
| Replies: 2 Views: 285 A static data member?
class foo {
private:
static bool vis;
char ch;
public:
void change_vis() { vis = !vis ;} |
Forum: C++ Aug 22nd, 2009 |
| Replies: 12 Views: 747 try here (http://go.microsoft.com/fwlink/?LinkId=51411&clcid=0x409) |
Forum: C++ Aug 21st, 2009 |
| Replies: 4 Views: 390 if your file looks just like the example you give, why not read each line into separate strings. If the second string has the value you interpret as activated, then use the password found in the... |
Forum: C++ Aug 16th, 2009 |
| Replies: 9 Views: 373 Oops, pulling head out of nether regions! I misread it as a factorial computation.
Recursive functions and time travel stories - reasons aspirin was invented. |
Forum: C++ Aug 16th, 2009 |
| Replies: 9 Views: 373 Nope, it another commonly used function. Step through it.
One way you might examine what's happening, and get an understanding of recursion, is to get a bunch of small pieces of paper. Use a... |
Forum: C++ Aug 13th, 2009 |
| Replies: 2 Views: 221 keywords "private" and "public" must be all lowercase. You're throwing the compiler for a loop before you get anywhere.
Also, right off the the top, your getname( ) function must have return... |
Forum: C++ Aug 13th, 2009 |
| Replies: 3 Views: 252 for(int i = 0; i <= Flowers; i++){
Flowers[i] = i + 1;
Don't you mean FlowersInHeap[i] here?
And, the big problem, is using <= as the test comparison. For Flowers = 5, you are trying to... |
Forum: C++ Aug 8th, 2009 |
| Replies: 2 Views: 210 It depends on the size and complexity of program you're trying to write. If it's a small program and the validation is short and simple, it would not be wrong to check the arguments in main( ). If... |
Forum: C++ Aug 8th, 2009 |
| Replies: 9 Views: 295 (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++ Aug 1st, 2009 |
| Replies: 3 Views: 270 fin.getline( message, MESSAGE_SIZE, '\0' );
-or-
getline( fin, message, '\0' );
These cause the input to read till a NULL is encountered, which should never happen. Thus, it will read till end... |
Forum: C++ Jun 9th, 2009 |
| Replies: 7 Views: 479 Printer - yes. Mouse/trackball, not so much. A stream is the source or destination of a series of data, either characters, or in the case of binary files, a sequence of bytes that represent memory... |
Forum: C++ Jun 6th, 2009 |
| Replies: 7 Views: 411 How big a block are you reading from the source file? It might be the file I/O is your bottleneck if you read in many small chunks. |
Forum: C++ Jun 6th, 2009 |
| Replies: 6 Views: 285 Um, this is a C++ forum. You'll get more and better response in the C forum.
And, csurfer, using eof( ) in that manner is going to unreliable at the end of the file, last value read in could be... |
Forum: C++ Jun 6th, 2009 |
| Replies: 3 Views: 753 Or, have the outer loop go by steps of 2, and use its current value as the limit for the inner loop that prints the *s. |
Forum: Windows Vista and Windows 7 Jun 5th, 2009 |
| Replies: 2 Views: 337 Windows 7 is the next version of Windows, succeeding Vista.
But hey, you could have found that very easily with just a quick googling. Would have gotten you an answer about 21 minutes ago. |
Forum: C++ Jun 5th, 2009 |
| Replies: 5 Views: 355 I would expect temp to still be be an empty string.
Note that an empty string is one which has no content. It is not the same as NULL. |
Forum: C++ May 29th, 2009 |
| Replies: 13 Views: 908 Putting the break (or exit( )) inside the if block is not a wholly satisfactory method. The conditions in loop ought to indicate when/why the loop ends - don't hide surprises inside the body.
How... |
Forum: C++ May 22nd, 2009 |
| Replies: 12 Views: 1,019 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,019 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 18th, 2009 |
| Replies: 7 Views: 427 No, you reuse the input strings in a loop, assigning to an element of the array as you go along. Consider this example.
#include <iostream>
using namespace std;
class Point
{
private:... |
Forum: C++ May 17th, 2009 |
| Replies: 7 Views: 427 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 10th, 2009 |
| Replies: 6 Views: 623 And get rid of the excess "out<<" in your ostream method. It'll run as is, but give odd results. |
Forum: C++ May 8th, 2009 |
| Replies: 7 Views: 400 Same problem with your array r[] - you make it type char, you read in something you mean to use as the integer value.
If your variable names had more meaning, you might see these places where data... |