Search:

Type: Posts; User: Hikaru

Page 1 of 2 1 2

Search: Search took 0.02 seconds.

  1. Replies
    3
    Views
    1,826

    How do you do it by hand? For math problems you...

    How do you do it by hand? For math problems you should define the steps first instead of start writing code. Then you can put them in an algorithm.
  2. Replies
    3
    Views
    1,122

    Maybe a vector of pointers into the other list? ...

    Maybe a vector of pointers into the other list?


    #include <iostream>
    #include <string>
    #include <vector>

    namespace Hikaru
    {
    using std::vector;
  3. Replies
    10
    Views
    2,210

    Ah, thank you. I wasn't sure if there was a...

    Ah, thank you. I wasn't sure if there was a problem I was missing or not. Thank you for the help. :)
  4. Replies
    10
    Views
    2,210

    I'm sorry, I don't understand. Are you trying to...

    I'm sorry, I don't understand. Are you trying to tell me that my strDup is wrong? strDup("") works as it should and strDup(NULL) is a problem with the call, not the function. I should have added an...
  5. Replies
    6
    Views
    1,230

    Ah, gomen. :o A better way would throw an...

    Ah, gomen. :o A better way would throw an exception.


    #include <iostream>
    #include <stdexcept>
    #include <cmath>

    using namespace std;

    // the way you had it was okay, but this is probably...
  6. Thread: String Case

    by Hikaru
    Replies
    29
    Views
    2,976

    It might not work. C++ algorithms want a function...

    Nice! I like this one the best, very clean! It uses the vector commands, which is cooooool :) Thanks for this![/QUOTE]
    It might not work. C++ algorithms want a function object or function with C++...
  7. Replies
    6
    Views
    1,230

    You shouldn't print the result if there's an...

    You shouldn't print the result if there's an error. Maybe return a bool and only print if it's true?


    #include <iostream>
    #include <cmath>

    using namespace std;

    // the way you had it was...
  8. Replies
    10
    Views
    2,210

    foo doesn't look very useful. Maybe source should...

    foo doesn't look very useful. Maybe source should be where you get "random" and the function just returns the result of strdup?


    #include <stdio.h>
    #include <string.h>

    char* modifiable(const...
  9. Replies
    13
    Views
    2,282

    Reading the file completely for every letter is...

    Reading the file completely for every letter is really inefficient. You can use a map instead to store all of the letters and counts by reading the file just one time.


    #include <cctype>...
  10. Replies
    5
    Views
    1,102

    Where in the world do washing machines require a...

    Where in the world do washing machines require a passcode and go out of order if it's wrong?

    You will need a loop. Only stop the loop when the passcode is right or when the number of errors...
  11. Thread: StringList?

    by Hikaru
    Replies
    20
    Views
    2,443

    With a vector. :) std::vector...

    With a vector. :)


    std::vector<std::string> stringArray;
  12. Thread: c++ strings

    by Hikaru
    Replies
    8
    Views
    1,250

    Always use them! :) C++ strings are a replacement...

    Always use them! :) C++ strings are a replacement for C strings. They're safer, easier, and can do more with less code. You can even get a C string from a C++ string with the c_str member function...
  13. Thread: StringList?

    by Hikaru
    Replies
    20
    Views
    2,443

    How do you know it'll be slower? I read a lot,...

    How do you know it'll be slower? I read a lot, and just about everyone says that people worry too much about speed when they shouldn't. You should write programs that are correct and easy to...
  14. Replies
    14
    Views
    1,846

    It's probably like the register keyword. It was a...

    It's probably like the register keyword. It was a good idea at the time but someone realized that the compiler is better at the job than programmers. :)
  15. Replies
    13
    Views
    1,517

    Please excuse my rudeness, System_159. I'm going...

    Please excuse my rudeness, System_159. I'm going to point out some things I think could be improved in your program.

    I'm told that macros are bad in C++. You should avoid them. Templates and...
  16. Replies
    3
    Views
    1,422

    That program should print the value of x, 0 to 99...

    That program should print the value of x, 0 to 99 without anything inbetween.


    012345678910111213141511617181920...

    Isn't that what you wanted to happen?
  17. Replies
    34
    Views
    3,685

    Thank you. :)

    Thank you. :)
  18. Replies
    34
    Views
    3,685

    I think that if you do it right, there won't be...

    I think that if you do it right, there won't be many try/catch statements so checking return values is the one that clutters your code.

    It looks like it.
  19. Replies
    34
    Views
    3,685

    I can only think of two ways. First, you can...

    I can only think of two ways. First, you can throw an exception. Or you can set a flag or something that code using the class can test for. fstreams use the flag, and I can't think of a C++ class...
  20. Replies
    16
    Views
    3,617

    I'm told that it specifically works on "files",...

    I'm told that it specifically works on "files", for whatever definition of a file ANSI C uses. But you shouldn't listen to me. I don't know much about C yet. :)
  21. Replies
    11
    Views
    2,809

    Normally being the key word. :) What if you need...

    Normally being the key word. :) What if you need more memory than the stack can hold? What if using static allocation would blow your executable way out of proportion? What if you don't know the size...
  22. Thread: Input

    by Hikaru
    Replies
    12
    Views
    1,460

    That's the problem, and I think it's because the...

    That's the problem, and I think it's because the left side of the || expression is saying "do this if the string isn't a null pointer". I'm sure that a quoted string will never be null, so the if...
  23. Replies
    8
    Views
    1,206

    Yeah, it is. :) It's also hard to use in C++...

    Yeah, it is. :) It's also hard to use in C++ since it's a function designed for C. C++ has better stuff like strings and stringstreams that are really intuitive and easy to use, not to mention a lot...
  24. Thread: Input

    by Hikaru
    Replies
    12
    Views
    1,460

    It's easy if you want an exact match. Just...

    It's easy if you want an exact match. Just compare the string variable with a quoted string.


    #include <iostream>
    #include <string>

    using std::cout;

    int main()
    {
  25. Replies
    8
    Views
    1,206

    Have you tried setting the stream to print in...

    Have you tried setting the stream to print in fixed or scientific notation?


    a_file << std::fixed <<"("<<P<<"*"<<L<<")"<<" ^ "<<T<<" /4= "<<A<<"\n";
Results 1 to 25 of 46
Page 1 of 2 1 2