Search:
Type: Posts; User: jlou
Search:
Search took 0.06 seconds; generated 59 minute(s) ago.
-
October 10th, 2008, 02:59 PM
That would just empty out the temporary string returned by the stringstream (if it was allowed at all since the string would be temporary). It wouldn't have any effect on the stream itself or the...
-
October 10th, 2008, 12:12 PM
Yeah... it's just one of those weird quirks of the language. They've already decided to fix it in the next standard.
-
October 10th, 2008, 11:59 AM
ofstream dvdfile(filename.c_str());In the current standard you can't pass an instance of the string class to an fstream constructor or open() function, you have to pass a C-style string.
-
October 10th, 2008, 11:53 AM
I'm not sure what the policy on bumping old threads is here, but this one is over four and a half years old.
The clear() just clears the failbit and/or eofbit (and the badbit, too, although that...
-
July 21st, 2008, 02:57 PM
Technically, <stdio.h> is standard in C++, so it will work on any standards-compliant compiler. It is deprecated, however, and you're right that you should use <cstdio> instead.
-
July 21st, 2008, 12:18 PM
You can format your output to any stream (whether it is an iostream or a stringstream) using manipulators from <iomanip>. For example, if you want your number output in hexadecimal with at least...
-
Interesting you should mention that. In this thread the site admin Brad Jones talks about the point of the "21 days" theme:
I think the idea is that there are 21 lessons, not that they should be...
-
Not everybody is learning from a book. Not every book teaches all concepts in a way that all readers understand.
I actually would prefer formats like this for clarifying understanding because the...
-
#include takes the contents of a header file and places where the #include was. (Technically it doesn't have to be a file but in practice it is.) The declarations for different input/output stream...
-
June 19th, 2008, 03:26 PM
I believe you're right laserlight. Note that if you use insert instead of operator[], you must remember that it behaves differently if the key already exists. You may have to use find() to verify...
-
June 19th, 2008, 03:22 PM
If any one of the compiler-generated destructor, copy constructor or copy assignment operator are inappropriate for a class, then it is likely that all three will compiler-generated functions will be...
-
June 19th, 2008, 03:16 PM
Dereference the pointer each time you want to use it as a string. In fact, I notice this needs to be done in other places as well.
If you're working on the pointer (e.g. setting it to null,...
-
June 19th, 2008, 03:07 PM
CurrentMessage = CurrentMessage + SymbolTemp;In that line of code, CurrentMessage is a pointer, so you are doing pointer addition. That's probably not what you wanted.
-
What happens if you use:
while(count < length && cin.good())
{
buffer1[count++] = cin.get();
if (buffer1[count-1] == '\0')
cerr << "Found a null character.";
}How do you know...
-
Since we're using doubles I think I would go ahead and use a double there instead of a float :)
virtual double GetVolume(){return (1.0/12)*(side *side*side)*sqrt(2.0);}
-
cin.get() works for me. Can you give an example that fails? What do you mean by "works", are you expecting cout to output something?
Why are you using cin? Is the data coming from the console?
-
"string" is a common computing term that describes a sequence of characters (or in some cases other things). There's nothing wrong with using it in this context. A null-terminated character array is...
-
The problem is that your code is set up to go through the entire Wordlist.txt file for each line in Words.txt. After the first time through, you don't reset the file stream to point to the beginning...
-
As long as you're accessing through the iterator you're ok. Of course it will end up being a char* and of course the underlying buffer of the string is changed, you are changing the string. The only...
-
Why do you think it is changing the underlying data buffer? That is only bad when you expose that buffer with c_str() and make changes directly to it. Here, tolower is called on each character in the...
-
It gets around the problem because code that uses your class cannot attempt to use it polymorphically, and specifically cannot delete it through a pointer to the base shared_ptr class.
Admittedly,...
-
rand() and RAND_MAX are standard in C++. They should work on other platforms, it's just that RAND_MAX might have a different value.
-
Instead of sizeof(line), use line.size().
Also, don't forget to reset x to 0 after each run of the inner loop. It might be better to use < instead of != because that would have caught this problem.
-
Public inheritance is generally meant to be used to implement polymorphic behavior. It models "is-a" or "works-like-a". In other words, you have code that works on a base class pointer or reference,...
-
If you wanted to you could achieve the same thing through composition or private inheritance.
|
Click Here to Expand Forum to Full Width
|