CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: jlou

Page 1 of 16 1 2 3 4

Search: Search took 0.12 seconds.

  1. Replies
    12
    Views
    96,531

    Re: How to clear out a stringstream

    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...
  2. Thread: File output name?

    by jlou
    Replies
    4
    Views
    716

    Re: File output name?

    Yeah... it's just one of those weird quirks of the language. They've already decided to fix it in the next standard.
  3. Thread: File output name?

    by jlou
    Replies
    4
    Views
    716

    Re: File output name?

    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.
  4. Replies
    12
    Views
    96,531

    Re: How to clear out a stringstream

    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...
  5. Replies
    7
    Views
    1,136

    Re: and

    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.
  6. Replies
    7
    Views
    1,136

    Re: and

    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...
  7. Replies
    4
    Views
    749

    Re: Need Advice...........

    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...
  8. Re: what is diff between #include and using namespace std

    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...
  9. Re: what is diff between #include and using namespace std

    #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...
  10. Re: Mapping objects without a default constructor

    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...
  11. Replies
    5
    Views
    711

    Re: Rule of 3 for a simple class...

    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...
  12. Replies
    4
    Views
    617

    Re: Help with Pointers

    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,...
  13. Replies
    4
    Views
    617

    Re: Help with Pointers

    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.
  14. Thread: cin NUL

    by jlou
    Replies
    8
    Views
    1,245

    Re: cin NUL

    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...
  15. Replies
    17
    Views
    14,338

    Re: hierarchy of shapes

    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);}
  16. Thread: cin NUL

    by jlou
    Replies
    8
    Views
    1,245

    Re: cin NUL

    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?
  17. Replies
    8
    Views
    1,141

    Re: Replacing single character

    "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...
  18. Thread: loop issues

    by jlou
    Replies
    2
    Views
    709

    Re: loop issues

    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...
  19. Thread: String conversion

    by jlou
    Replies
    18
    Views
    2,146

    Re: String conversion

    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...
  20. Thread: String conversion

    by jlou
    Replies
    18
    Views
    2,146

    Re: String conversion

    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...
  21. Replies
    9
    Views
    6,956

    Re: Deriving from shared_ptr

    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,...
  22. Thread: random doubles

    by jlou
    Replies
    9
    Views
    966

    Re: random doubles

    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.
  23. Thread: whats wrong?

    by jlou
    Replies
    2
    Views
    899

    Re: whats wrong?

    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.
  24. Replies
    9
    Views
    6,956

    Re: Deriving from shared_ptr

    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,...
  25. Replies
    9
    Views
    6,956

    Re: Deriving from shared_ptr

    If you wanted to you could achieve the same thing through composition or private inheritance.
Results 1 to 25 of 383
Page 1 of 16 1 2 3 4





Click Here to Expand Forum to Full Width

Featured