Search:

Type: Posts; User: riis

Page 1 of 13 1 2 3 4

Search: Search took 0.37 seconds.

  1. Replies
    4
    Views
    577

    Re: [RESOLVED] [C] Integer overflow

    For both signed and unsigned integers: if the result is smaller than one of the input values, then an overflow has occurred as well. If you add a negative value, treat it as a subtraction of a...
  2. Replies
    9
    Views
    711

    Re: Problums writeing struct to a file C++

    I wouldn't give a binary file a TXT extension ;)
  3. Replies
    2
    Views
    620

    Re: Can a class return a value?

    If the CAge class contains non-public members, and you want to output them, then you need to make the overloaded operator<< a friend of the class, or operator<< should call a method in the class...
  4. Replies
    9
    Views
    711

    Re: Problums writeing struct to a file C++

    In case you want this to be a part of a struct/class, you should create methods named "read" and "write" (or what you prefer). Since these methods are part of the struct/class, they have the...
  5. Replies
    9
    Views
    711

    Re: Problums writeing struct to a file C++

    Writing the string


    char *str;
    int stringLen = 100;

    str = new char[stringLen]; // Allocate memory the C++ way if you're using C++
    memset(str, 0, stringLen); // The new operator doesn't...
  6. Thread: side effects

    by riis
    Replies
    7
    Views
    510

    Re: side effects

    Ah, I see, the ^ isn't relevant here. Any binary operator could've caused this "effect".

    It's pretty much the same as that the evaluation order of function parameters doesn't have a fixed order,...
  7. Thread: side effects

    by riis
    Replies
    7
    Views
    510

    Re: side effects

    Expressions within parentheses are always evaluated first, before the surrounding expression is evaluated. In case of assignments, they're executed during evaluation.
    It would be an error if the...
  8. Replies
    7
    Views
    568

    Re: quick question about loop

    Indentation (directly before printing the first date):


    int i;
    for(i = 1; i < d; i++)
    {
    printf(" "); // three spaces
    }

    The code will not print an indentation when d = 1 (since the...
  9. Re: [answered]saving and loading external files (C++)

    I'm not twanvl, but I hope you don't mind ;)

    In C++ the file classes are implemented as streams, just like cin/cout. Since there are several different types of streams (files, stringstream,...
  10. Thread: Recommended books

    by riis
    Replies
    0
    Views
    411

    Recommended books

    Hello all,

    A while back I came across a great site (Association of C and C++ Users, ACCU) which contains many book reviews on many subjects (but mainly aimed at C and C++). If you're have some...
  11. Replies
    5
    Views
    845

    Re: [RESOLVED] using namespace std; or std::

    Sometimes the namespace prefix doesn't help you. Today I had a case with std::min and std::max. I was using them (VC++6) in my code, but I also included Windows.h, defining NOMINMAX in order to be...
  12. Replies
    16
    Views
    862

    OT, compiler advice

    It's off-topic, but you should know that there are many free compilers which support the latest C++ standard*, so you can use STL, etc. Examples are mingw, cygwin, borland C++ builder 5.5,...
  13. Re: Help Displaying data form an Array

    There are several things going wrong here with "resizing the array" and "storing the file name".
    I could do two things now, namely 1) explain what's going wrong and way, and tell you a much better...
  14. Replies
    8
    Views
    600

    Re: \n or endl

    This depends how the stream is opened. If it's a text stream (no std::ios::binary), then it is different, because Windows always inserts a carriage return before the newline. If it's a binary stream...
  15. Re: Is it possible to use the loop to calculation of geometric area?

    Nice formula, I've never seen it :)

    My way is much simpler to visualize. You can consider it as the integration between points i and j. The needed division by two (average Y value) is done later...
  16. Replies
    16
    Views
    2,966

    Re: helpp!! i want to swap 3 digit number

    Not in c/c++, it's not a monster like IIf in VB, although the syntax looks monstrous :)
  17. Replies
    16
    Views
    2,966

    Re: helpp!! i want to swap 3 digit number

    Another way to get the sign is: int sign = (val != 0) ? val / abs(val) : 0;
    Then: val = abs(val);
    and execute the rest of the code.
  18. Replies
    1
    Views
    336

    Re: Reading Files/Folders

    In case you're programming for Windows, look up the FindFirstFile / FindNextFile API's at MSDN.
  19. Thread: Syntax question

    by riis
    Replies
    6
    Views
    611

    Re: Syntax question

    It looks like a constructor, but it is not.
    The problem is that "blahClass" and "blahFunction" should be equal, in order to be a constructor.

    If this is the case then
    blahClass::blahClass()
    :...
  20. Replies
    1
    Views
    660

    Re: switch row to column

    If you're reading the data with a loop like "for(i = 0; i < row; i++) { for(j = 0; j < column; j++) ... }", and you want to transpose (switch rows and columns) it, you should write it with a look...
  21. Replies
    6
    Views
    954

    Re: Reference 2d array AS 2d array?

    There's nothing wrong with that. The only relevant difference between a 1D and 2D array in this case is that a 2D array is a 1D array, cut in parts of equal length, and stacked below each other.
    ...
  22. Thread: min()function

    by riis
    Replies
    3
    Views
    414

    Re: min()function

    There's a problem in the line "for (cluster = 0; cluster < cluster_num; cluster++)"
    Check for "cluster < cluster_num - 1" or bad things (undefined behaviour) will happen.
    Also, your code doesn't...
  23. Replies
    16
    Views
    2,966

    Re: helpp!! i want to swap 3 digit number

    I've djusted Wossname's code a bit. It's also valid C/C++ now.
    There's no need to check for 0 or to calculate the number of digits.

    BTW, it won't work for negative integers.
  24. Replies
    6
    Views
    534

    You're not setting the "reference" of the...

    You're not setting the "reference" of the variable to another variable, but the address.
    This line (CONTROLSET * msgCSet = &Cset;) is wrong, since Cset is already a pointer to CONTROLSET. You should...
  25. Replies
    5
    Views
    498

    I guess you mean addr & ~0x03 :)

    I guess you mean addr & ~0x03 :)
  26. Replies
    10
    Views
    631

    When you got the lib file, weren't there any...

    When you got the lib file, weren't there any other files at the place (or perhaps documentation)? If you only have a lib file, then you can't do much.

    (Perhaps there are tools which generate...
  27. Replies
    10
    Views
    631

    If the function is meant to be called from VB,...

    If the function is meant to be called from VB, then the "calling convention" should be mentioned in the function somewhere. It has to do with the way how VB calls function, as opposed to C. I won't...
  28. Replies
    10
    Views
    631

    You need a header file where the function is...

    You need a header file where the function is declared. (Or if you know the exact definition of the function, you can put it in one of your own header files.)

    Apparently it's something like:

    ...
  29. Thread: Stack Or Heap???

    by riis
    Replies
    10
    Views
    619

    He said 32 bit. A DWORD is made up of two WORDs,...

    He said 32 bit.
    A DWORD is made up of two WORDs, and one WORD is made up of two bytes. Those are types used in windows. As you know, a byte is made up of eight bits, so 8 * 2 * 2 = 32 bits for a...
  30. Replies
    5
    Views
    923

    Perhaps you're including the file with the class...

    Perhaps you're including the file with the class definition multiple times?
    Place include guards around the content of the class definition file to prevent it from being included two or more times....
  31. Replies
    21
    Views
    718

    *.png of course :)

    *.png of course :)
  32. Replies
    2
    Views
    2,422

    List of nodes at the various stages: D DB...

    List of nodes at the various stages:

    D
    DB
    DBA
    DBC
    DF
    DFE
    DFG
  33. Replies
    2
    Views
    2,422

    Suppose you have the following (binary) tree (D...

    Suppose you have the following (binary) tree (D is the root):


    D
    / \
    B F
    / \ / \
    A C E G
  34. Thread: Compile Errors

    by riis
    Replies
    1
    Views
    417

    You should look in the last line of code before...

    You should look in the last line of code before line 125. Look at the end to see if there is a semicolon present.
    Keep in mind that compile errors often are related to previous code.
  35. Replies
    199
    Views
    12,737

    Aren't we using logic then? ;) The only thing...

    Aren't we using logic then? ;) The only thing that is random in my program is that it's completely unbiased in which direction the player should go the next move. There's no fixed set of rules from...
  36. Replies
    6
    Views
    386

    picosecond (10-12 second) femtosecond (10-15...

    picosecond (10-12 second)
    femtosecond (10-15 second)
    attosecond (10-18 second)
  37. Replies
    199
    Views
    12,737

    The deadline has been extended to next sunday, so...

    The deadline has been extended to next sunday, so you still have a couple of days to work on it any further. Electroman also has posted it on the first page of this thread.
  38. Replies
    199
    Views
    12,737

    Steven, I do not agree with your opinion. The way...

    Steven, I do not agree with your opinion. The way how you implement your algorithm is a choice. You'll be lucky, or you'll be unlucky with your guess. I see that as a part of the game. If I would be...
  39. Replies
    13
    Views
    636

    (From the first code block.) A few questions:...

    (From the first code block.)

    A few questions:
    * Does any_string have a c_str method? It's not mentioned in your first post.
    * What does any_string_cast do?
    * Why can't you also use the c_str...
  40. Replies
    13
    Views
    636

    In what circumstances do you intend to use...

    In what circumstances do you intend to use any_string.
    Only as a function argument, or will it be possible to replace any_string throughout the entire program where it's used? (The latter will be...
Results 1 to 40 of 500
Page 1 of 13 1 2 3 4



Click Here to Expand Forum to Full Width