Search:

Type: Posts; User: Edward

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    1,057

    right aligns the output to the right. showpos...

    right aligns the output to the right. showpos prints a +, noshowpos does the opposite. setfill lets you change the empty space characters set by setw. If you set the field width to 5 and only print 4...
  2. Replies
    3
    Views
    2,158

    Since you probably aren't compiling from the...

    Since you probably aren't compiling from the command line, you'll probably find the command line settings under Projects->Settings. As I said, I don't think that Visual Studio defines the stdprn...
  3. Replies
    3
    Views
    2,158

    Compilers will generally use extensions by...

    Compilers will generally use extensions by default, relying on a switch to engage pure ANSI conformance. I believe that the switch in Visual Studio is /Za to enable and /Ze to disable. However, if...
  4. Replies
    2
    Views
    932

    c = a + b; Local variables aren't initialized...

    c = a + b;

    Local variables aren't initialized to anything in particular, so there is no way to predict what the value of c will be after this statement. Move it down in your code to a place after...
  5. Replies
    4
    Views
    1,057

    #include #include using...

    #include <iostream>
    #include <iomanip>

    using namespace std;

    int main()
    {
    // Display column header
    cout<<" ";
    for (int col = 0; col < 10; col++)
  6. Thread: Malloc

    by Edward
    Replies
    5
    Views
    1,414

    You shouldn't cast the return of malloc in C. It...

    You shouldn't cast the return of malloc in C. It hides the error of not including stdlib.h. An accepted convention of calling malloc is to multiply the amount by the size if the dereferenced pointer...
  7. Replies
    2
    Views
    1,607

    cout determines the type of a variable you pass...

    cout determines the type of a variable you pass it and prints the appropriate representation. In this case your variables are of the type s8 and u8, which are typedef'd char types. So cout sees chars...
  8. Replies
    1
    Views
    786

    Yes to all three questions. Though how you can...

    Yes to all three questions. Though how you can choose to go about each is different. The simplest way to go about the first is simply to print out the numbers and ignore the number that was input.
    ...
  9. Thread: entire file

    by Edward
    Replies
    30
    Views
    3,734

    You're clearly imagining things. I can't find...

    You're clearly imagining things. I can't find anything that even remotely resembles "troll trash remarks" in my posts. Yours on the other hand have a few. I'm reporting this thread to be closed.
  10. Thread: entire file

    by Edward
    Replies
    30
    Views
    3,734

    You're far too sensitive. Perhaps you should go...

    You're far too sensitive. Perhaps you should go back and read my posts. You'll notice the presence of a ;) in the first one. Immediately after that you take offense and now you try to insult me. You...
  11. Replies
    3
    Views
    6,312

    How a number is represented is irrelevant when...

    How a number is represented is irrelevant when working with binary. Decimal, octal, hexadecimal are all the same when viewed as a sequence of bits. The code simply tests a single bit at a time with...
  12. Replies
    10
    Views
    1,263

    When converting your array, walk back from the...

    When converting your array, walk back from the end. You can find the end with strlen. Then, instead of using a calculation, a variable marking the current bit level would be much easier.

    ...
  13. Thread: entire file

    by Edward
    Replies
    30
    Views
    3,734

    True. But will the size of the file be the size...

    True. But will the size of the file be the size that you expected?

    Not in your snippet unless I'm going blind (that I wear glasses suggests that this could very well be the case). However, in the...
  14. Thread: entire file

    by Edward
    Replies
    30
    Views
    3,734

    Which one? The bug that assumes nbytes is really...

    Which one? The bug that assumes nbytes is really the size you want, the bug that results in a null pointer access if malloc fails or the bug that results in a null pointer access if fopen fails? ;)
  15. Replies
    4
    Views
    5,380

    I think it would go a long way toward making...

    I think it would go a long way toward making portable threaded applications less of a hassle. But don't you think this thread would be better suited to the General Discussions forum?
  16. Replies
    3
    Views
    6,312

    You're basically counting set bits in a value....

    You're basically counting set bits in a value. This can be done easily by just testing the first bit and shifting right by one until the value is 0.


    unsigned count(unsigned value)
    {
    int n...
  17. Replies
    17
    Views
    2,529

    c = getchar(); if (c == EOF || (c != 'P' && c !=...

    c = getchar();
    if (c == EOF || (c != 'P' && c != 'L' && c != 'Q')) {
    // Handle bad input
    }
    // Use c
  18. Replies
    12
    Views
    1,527

    This situation is one of those uses. The usual...

    This situation is one of those uses. The usual suggestion of using a status variable is both wasteful and clutters the code. So many people find this to be perfectly reasonable.


    while...
  19. Replies
    4
    Views
    4,900

    Yours is a common problem. If you search the web...

    Yours is a common problem. If you search the web you'll find plenty of implementations in C.
  20. Thread: Stack::push

    by Edward
    Replies
    4
    Views
    1,416

    You're looking at a simple assignment of...

    You're looking at a simple assignment of pointers. With the complexity of an explicit constructor call removed, the code would look like this.


    void Stack::Push(void* dat) {
    Link* newLink =...
  21. Replies
    10
    Views
    3,390

    Have you written the code to read a single record...

    Have you written the code to read a single record from the file? Once you can do that, it's a simple matter to read multiple records with a loop. Formatting the output is equally simple when you have...
  22. Replies
    11
    Views
    2,182

    A straightforward technique for arbitrary length...

    A straightforward technique for arbitrary length numbers and arithmetic on those types is to store the data as strings of characters. Each character represents a part of the number such as a digit or...
  23. Replies
    7
    Views
    2,370

    You have two distinct problems. First is that you...

    You have two distinct problems. First is that you try to use an uninitialized pointer. If you want a dynamic array then you must allocate the memory for it before using it. Your second problem is...
  24. Replies
    7
    Views
    2,370

    Post a small working example. I don't quite...

    Post a small working example. I don't quite understand what problems you are having.
  25. Replies
    7
    Views
    2,370

    Well, it appears as if you want a simple output...

    Well, it appears as if you want a simple output statement.


    cout<< points <<endl;
Results 1 to 25 of 47
Page 1 of 2 1 2