Search:

Type: Posts; User: PorkyChop

Page 1 of 6 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    8
    Views
    1,002

    If you're really concerned about speed, and you...

    If you're really concerned about speed, and you don't mind pointer arithmetic, behold the fastest way:



    #include <iostream>

    int main()
    {
    char foo[] = "BlahThis is a test\0";
    cout...
  2. ifstream stream("blah", ios::binary); //Let's...

    ifstream stream("blah", ios::binary);

    //Let's say you want to read 10 bytes from the file
    char buffer[10];
    stream.read(buffer, 10);

    //And you want to save your position
    //streamoff is the...
  3. Replies
    3
    Views
    1,539

    I could be wrong on this, but I think that...

    I could be wrong on this, but I think that because you've declared nodeType as a struct and given it no constructor, the new operator does not know to initialize the left and right pointers to NULL,...
  4. Replies
    8
    Views
    1,217

    You'll want to open the file in binary mode, and...

    You'll want to open the file in binary mode, and then use the stream's seekg() method to go to the right position in the file, and then use steam's read() method to actually read the data.


    ...
  5. Thread: pow() help

    by PorkyChop
    Replies
    4
    Views
    1,035

    For my compiler(GCC 3.4.3) mathcalls.h defines...

    For my compiler(GCC 3.4.3) mathcalls.h defines pow to take two doubles for arguments. I tested it and the statement:


    pow(20.0, 1.0/3.0);

    works just fine.
  6. Thread: randomizing?

    by PorkyChop
    Replies
    55
    Views
    6,130

    I really hope this helps... #include...

    I really hope this helps...



    #include <iostream>
    #include <cstdlib>
    #include <ctime>


    using namespace std;
  7. Thread: Bug in Code

    by PorkyChop
    Replies
    9
    Views
    1,537

    Not one of you has presented a correct version of...

    Not one of you has presented a correct version of a main definition in code...



    int main( int argc, char* argv[] ) //or char** argv
    {
    //...
    // return 0; is implicit
    }
  8. Replies
    30
    Views
    2,875

    It doesn't work as in it doesn't compile, or as...

    It doesn't work as in it doesn't compile, or as in the string isn't erased? If it's the former, what's the compiler's output? Help us out here, dude.
  9. Replies
    30
    Views
    2,875

    You need to have included if you don't...

    You need to have <string> included if you don't already.
  10. Replies
    30
    Views
    2,875

    You'd probably have better results if you used...

    You'd probably have better results if you used whatever magic number you used to create the array for the size argument of memset, rather than the sizeof operator.
  11. Replies
    30
    Views
    2,875

    To clear a string, you would use the following...

    To clear a string, you would use the following line:



    string foo;

    foo.erase();
  12. Replies
    30
    Views
    2,875

    #include using namespace std; ...

    #include <string>

    using namespace std;

    //...


    string foo;

    cin >>foo; //or getline(cin, foo) for \n terminated
  13. Replies
    2
    Views
    1,613

    Please use code tags next time. It looks like...

    Please use code tags next time.

    It looks like your main problem is this:


    cin >> ( D || A || C || X );

    That line should be:
  14. Thread: Need help!

    by PorkyChop
    Replies
    7
    Views
    1,281

    cout, cin, and endl are in the std namespace, and...

    cout, cin, and endl are in the std namespace, and you haven't specified that they are. There are two ways to do this. The first way is to specify it manually with the scope resolution operator( :: )...
  15. Replies
    4
    Views
    1,142

    Just for the future, code tags are in square...

    Just for the future, code tags are in square braces( [ ), not angle braces. I'm not sure I completely understand what you're trying to do, but I'm assuming you'd like to input certain data types from...
  16. Replies
    20
    Views
    72,810

    >i think the floating point version of ( 22 / 7 )...

    >i think the floating point version of ( 22 / 7 ) might also be another way

    22/7 is kind of like pseudo-PI. If you type that into a calculator, you'll get 3.142857, and the first few digits of PI...
  17. Replies
    20
    Views
    72,810

    My only doubt would be that M_PI may may be one...

    My only doubt would be that M_PI may may be one the the "math constants" that was referred to in your quote. But as far as I can remember, it has been there on every compiler I have used(maybe...
  18. Replies
    20
    Views
    72,810

    I think the M_PI macro in is standard,...

    I think the M_PI macro in <cmath> is standard, but I'm not sure.
  19. Replies
    18
    Views
    3,080

    >So you can have variable length arrays in C++? ...

    >So you can have variable length arrays in C++?

    You'd have to allocate them dynamically but yes. Or in cases where appropriate, you could use a vector

    >You can not cast void * when assigning to...
  20. I've got a little tip for you to make your...

    I've got a little tip for you to make your algorithm much cleaner. In ASCII code, the only difference between a letter and the same letter of the opposite case is the fifth bit of the character....
  21. Replies
    18
    Views
    3,080

    C++ is an object-oriented language. It...

    C++ is an object-oriented language. It facilitates all of the main principles of object orientation( data abstraction, inheritance, polymorphism, etc. ), and it allows for you to express your program...
  22. Alright, just one more post and then I'll quit my...

    Alright, just one more post and then I'll quit my belly achin'.


    If volunteers can create an operating system in 7 years, I don't see any reason why they can't update a few C++ tutorials. These...
  23. Type http://www.cprogramming.com into a browser...

    Type http://www.cprogramming.com into a browser and read the tutorials. As far as I'm concerned, your current information is right there.


    I understand that changes like that can't be made...
  24. CProgramming.com should update their tutorials.

    I first learned how to code in C++ mainly from CProgramming's tutorials, and I think they have a lot of merit. They are thorough(on the subjects covered) and are great for beginners. But they have...
  25. Replies
    2
    Views
    868

    In the world of operating systems, there are two...

    In the world of operating systems, there are two kinds of interfaces to the user. The one you are familiar with and use pretty much all of the time is referred to as a Graphical User Interface, or...
Results 1 to 25 of 126
Page 1 of 6 1 2 3 4