Search:

Type: Posts; User: Inanna

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    3
    Views
    1,183

    Custom operator

    Custom operator<<'s should be nonmember friends. But I think a bigger problem is why do you need an ofstream container class? What is CfgFile supposed to do that ofstream can not do? There is...
  2. Replies
    3
    Views
    718

    If you find one, let me know. ;)

    If you find one, let me know. ;)
  3. Have you tried declaring loopcount? :D

    Have you tried declaring loopcount? :D
  4. Replies
    10
    Views
    967

    Working fine is one possible effect of undefined...

    Working fine is one possible effect of undefined behavior. That does not mean it will work anywhere else, or even on your end if you try again. Undefined behavior means 100% unpredictable.


    Did...
  5. Replies
    10
    Views
    967

    setw() only applies for the next thing you print....

    setw() only applies for the next thing you print. For the rows, the width is set to 10 for "row ". The row number starts on the 11th spot.


    The blue line is not correct because it is undefined...
  6. Replies
    11
    Views
    823

    calloc() just combines malloc() and memset() with...

    calloc() just combines malloc() and memset() with a value of 0. It is not safe to use memset() on anything but int or char types. You have to initialize the members separately.


    struct RunParam*...
  7. Replies
    6
    Views
    917

    Can you post the code that did not work like you...

    Can you post the code that did not work like you wanted?
  8. Replies
    6
    Views
    917

    Use an else if before the else if (first) {...

    Use an else if before the else


    if (first)
    {
    ...
    }
    else if (second)
    {
    ...
  9. If it is a text file you can call ftell() just...

    If it is a text file you can call ftell() just before reading the line for seeking back.


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

    void strip_linebreak(char* s);

    int main()
    {
  10. Replies
    3
    Views
    948

    You have an address operator on final_score. That...

    You have an address operator on final_score. That makes printf print the address of final_score instead of the value of final_score.
  11. Replies
    13
    Views
    3,054

    The OP does not have that option. malloc() is...

    The OP does not have that option. malloc() is also not an option. The exercise is to simulate malloc with an array of char. Good idea or not, that is a restriction that can not be thrown out. How...
  12. Replies
    13
    Views
    3,054

    How would you do it?

    How would you do it?
  13. Replies
    13
    Views
    3,054

    It is the other way around. Pointers into the...

    It is the other way around. Pointers into the memory array are given out and the memory is used through those pointers.


    #include <stdio.h>

    static char memory[1024];
    static int current = 0;
    ...
  14. Replies
    5
    Views
    800

    Unless reads and writes are interspersed, it is...

    Unless reads and writes are interspersed, it is simpler to use two fstream objects pointed to the same file.
  15. Replies
    3
    Views
    907

    You have the right idea with the commented out...

    You have the right idea with the commented out line


    //colorVal [walk +1] = colorVal[walk];

    But that is only part of sorting colorVal too. You also have to have a hold for colorVal.


    void...
  16. Thread: Dereferencing

    by Inanna
    Replies
    1
    Views
    794

    If you look at this page...

    If you look at this page, [] has higher precedence than *. Without parentheses to swap the order of those two, the *(ap + i)[j] has the effect of *ap[i+j], or ap[i+j][0].
  17. Thread: file name input

    by Inanna
    Replies
    2
    Views
    1,118

    You mean from the user? char...

    You mean from the user?


    char filename[BUFSIZ];

    printf("Enter file name: ");
    fgets(filename, BUFSIZ, stdin);

    FILE* fp = fopen(filename, mode);
  18. There are 1 million microseconds in 1 second. And...

    There are 1 million microseconds in 1 second. And I do not think time_t can hold that result. You probably need a bigger type.
  19. time_t is the number of seconds since the epoch...

    time_t is the number of seconds since the epoch on ubuntu. With the number of seconds, it is easy to get the microseconds by multiplying that value by 1,000,000. Just be careful about overflowing...
  20. Replies
    4
    Views
    1,815

    This should not even compile. Casting with...

    This should not even compile. Casting with parentheses looks like this


    float a = (int)b / 10;

    or this


    float a = int(b) / 10;
  21. Replies
    6
    Views
    1,592

    This is what I want. Books and exercises show...

    This is what I want. Books and exercises show things in a sandbox. OOP examples are the worst because they are contrived and unrealistic. I can tell you how OO works in C++ but I am not confident I...
  22. Replies
    3
    Views
    1,790

    This is a little off topic, but if you have a...

    This is a little off topic, but if you have a compiler with C++0x or C++03 TR1, the mt19937_64 class will give you 64 bit random numbers with the mersenne twister algorithm. It is a much better way...
  23. Replies
    12
    Views
    3,119

    Even char has an implementation defined size....

    Even char has an implementation defined size. sizeof(char) is always 1, but the number of bits in char does not have to be 8. 8 bits is the norm though, so this bit of trivia is really only good for...
  24. Replies
    3
    Views
    1,677

    Default arguments are kind of like a shorter,...

    Default arguments are kind of like a shorter, faster way of overloading. The getline() example might look like this without default arguments:


    istream& getline(istream& in, string& s, char...
  25. Replies
    20
    Views
    3,458

    Adding a level of indirection does not change the...

    Adding a level of indirection does not change the rules. Pointers are very consistent. But you are always free to believe what you want, and I wish you the best of luck. :)
Results 1 to 25 of 69
Page 1 of 3 1 2 3