Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.14 seconds; generated 7 minute(s) ago.

  1. Replies
    10
    Views
    127

    It really isn't so hard: // read string as...

    It really isn't so hard:

    // read string as float, apply function , write int as string
    float x;
    while (file_in >> x)
    {
    file_out << float_to_fixed(x) << '\n';
    }
    But you didn't even bother...
  2. Replies
    10
    Views
    127

    I thought that you were dealing with fixed point...

    I thought that you were dealing with fixed point numbers, and were reading as float and then converting to fixed point for calculations.


    Because if you're working with fixed point, then going...
  3. Replies
    10
    Views
    127

    Oh, then where does fixed point come into play? ...

    Oh, then where does fixed point come into play?

    EDIT:
    Oh, okay, I think I understand: 'write the converted value to a file named "file_out.txt"'. In that case, there's nothing more to do. Just...
  4. Replies
    10
    Views
    127

    This doesn't sound like a good idea: you might...

    This doesn't sound like a good idea: you might lose accuracy reading the input as a float to begin with. Why not read the input as a string then write and apply a string_to_fixed function?
  5. Replies
    21
    Views
    439

    The thing is that declaring those two parameters...

    The thing is that declaring those two parameters as const is only useful to the implementation of the function, i.e., to prevent an accidental modification of parameters that should not be modified,...
  6. Replies
    4
    Views
    120

    That is a simple function-style macro. What are...

    That is a simple function-style macro. What are you having trouble understanding?

    If the difficulty in understanding lies with __builtin_expect rather than the macro feature, then read the manual:...
  7. Replies
    8
    Views
    255

    There may be another alternative: declare the...

    There may be another alternative: declare the array with static storage duration. This could mean using the static keyword, or it could mean moving the array declaration to file scope. You then...
  8. Replies
    1
    Views
    93

    Yes, you have a chance with at least three ways:...

    Yes, you have a chance with at least three ways:

    Copy the token to an array of char member in the struct. However, you need to know how long the longest token can be in order to declare the array...
  9. Replies
    4
    Views
    120

    You need to realise that this is the definition...

    You need to realise that this is the definition of a function-style macro. Thus, it needs to be on one logical line only. To spread it across multiple physical lines for readability, the backslashes...
  10. Replies
    6
    Views
    159

    I'm still really puzzled as to why your...

    I'm still really puzzled as to why your instructor wants to use dynamic memory allocation instead of yet another 2D array, but let's chalk that up to you learning dynamic memory allocation for a...
  11. Replies
    6
    Views
    159

    So, this is a school project with artificial...

    So, this is a school project with artificial constraints? Then indeed you have to use a triple pointer, but you should also be aware that this might be because your instructor is a three star...
  12. The error means that you tried to assign to an...

    The error means that you tried to assign to an array. That is not allowed in C. You can initialise an array with an aggregate, e.g.,

    int numbers[] = {1, 2, 3};
    But once the array exists, you...
  13. Replies
    3
    Views
    141

    This appears to have been superseded by Problem...

    This appears to have been superseded by Problem of allocation memory, so I shall close this thread.
  14. Replies
    6
    Views
    159

    You seem to have a fundamental problem: you're...

    You seem to have a fundamental problem: you're dealing with matrices of ROWS number of rows and COLS number of columns. You cannot multiply two such matrices unless they are square matrices.

    If...
  15. Replies
    8
    Views
    164

    According to C11, you're relying on "other...

    According to C11, you're relying on "other implementation-defined characters", since $ is not in the list of non-digits and does not have the form of a universal character name. Anyway, it is...
  16. Replies
    3
    Views
    141

    Notice that when you allocate, you're only...

    Notice that when you allocate, you're only looping over ROWS, both in the outer and inner loops.

    My guess is that you want the outer loop to loop over ROWS and the inner loop to loop over COLS...
  17. Replies
    8
    Views
    246

    It is legal C syntax. That's the one thing both...

    It is legal C syntax. That's the one thing both Malcolm McLean and john.c agree on, and they are right.


    In matters of "should or should not be allowed", programmers are entitled to their own...
  18. Replies
    8
    Views
    164

    I don't think that's a valid symbol in C. You...

    I don't think that's a valid symbol in C. You might be looking at someone's attempt to tell you that whatever comes next should be run at the command line.

    If you don't understand what I just...
  19. Replies
    4
    Views
    269

    My concern would be the representation of the...

    My concern would be the representation of the double: as far as I know, IEEE 754 is not guaranteed. With the unknowns that you have listed, it seems to me that your task is iffy: if you don't know...
  20. Replies
    1
    Views
    144

    Read this website's tutorial on command line...

    Read this website's tutorial on command line arguments.
  21. Replies
    4
    Views
    269

    Is this binary file in a pre-defined format, or...

    Is this binary file in a pre-defined format, or do you have control over the whole process, i.e., you just want a portable way to write to a file in a binary format that you can read from?

    If it...
  22. Are you basically implementing a semaphore?

    Are you basically implementing a semaphore?
  23. Yes, like this: std::string...

    Yes, like this:

    std::string format_time(std::time_t time_value)
    {
    std::string result(20, '\0');
    std::strftime(&result[0], result.size(), "%d/%m/%Y %T", std::localtime(&time_value));
    ...
  24. There are two problems with your code: The...

    There are two problems with your code:

    The std::string is empty.
    You're calling c_str(), which returns a const char*, and then casting away the constness, which could be problematic if the...
  25. Replies
    21
    Views
    439

    That's what I mean by "Either that, or you reuse...

    That's what I mean by "Either that, or you reuse a suitable member, but that's code obfuscation."

    Basically, instead of properly designing a way to convey the number of items, you're obfuscating...
Results 1 to 25 of 495
Page 1 of 20 1 2 3 4