Search:

Type: Posts; User: swoopy

Page 1 of 20 1 2 3 4

Search: Search took 0.05 seconds.

  1. Replies
    4
    Views
    1,820

    >Write a program that will allow randomized...

    >Write a program that will allow randomized 0..100 numbers
    > random_integer = (rand()%100)+1;
    That gives you numbers from 1..100.
  2. Replies
    3
    Views
    959

    >Is it possible? if yes, how do I do it? Try...

    >Is it possible? if yes, how do I do it?
    Try this.

    #include <cstdlib>
    #include <iostream>
    #include <string>

    int main()
    {
    std::string tag;
  3. Thread: FEOF Error

    by swoopy
    Replies
    8
    Views
    6,869

    > char c; Declaring c as an int will...

    > char c;
    Declaring c as an int will likely fix your problem. Also a better way to control the loop is:


    while((c=fgetc(fp)) != EOF)
    {
  4. Replies
    6
    Views
    1,788

    It depends on what function you use to write each...

    It depends on what function you use to write each data item or struct. If you use fprintf(), then text mode should be fine. If you use fwrite(), then you need to use binary mode.
  5. Replies
    6
    Views
    1,670

    This is C, not C++.

    This is C, not C++.
  6. Replies
    16
    Views
    4,565

    Yeah, having two names is probably just for...

    Yeah, having two names is probably just for convenience. It makes it easier to read code. It seems like they could have just had one function, but maybe coming up with a good name would be a...
  7. Replies
    16
    Views
    4,565

    I'd be very surprised if that's the case.

    I'd be very surprised if that's the case.
  8. Replies
    16
    Views
    4,565

    >I did not use the ntohl or htonl because I have...

    >I did not use the ntohl or htonl because I have to choose which one. This works both ways with the same routine
    As long as you don't sometime in the future run your code on a different platform,...
  9. Replies
    16
    Views
    4,565

    >and it prints the correct value Just be sure...

    >and it prints the correct value
    Just be sure you assign the result to something back in process_cmd().
  10. Replies
    16
    Views
    4,565

    And you never assigned the return value to...

    And you never assigned the return value to anything:

    var = BYTESWAP2(ccmd);

    Or you could simply print out the value of BYTESWAP2(ccmd).
  11. Replies
    16
    Views
    4,565

    You have two of your masks incorrect, this one...

    You have two of your masks incorrect, this one ((ccmd&0x000000FF)<<24) and ((ccmd&0xFF000000)>>24). And for maximum portability, the input to BYTESWAP should be an unsigned int:

    int...
  12. Replies
    9
    Views
    2,662

    >The problem is, what happens when you want to do...

    >The problem is, what happens when you want to do arithmetic on the stuff that is being put in?
    _getch() only inputs a single number per call, so if the user entered 123, you'd have to combine them...
  13. Replies
    12
    Views
    1,649

    >Why does this tell me i'm missing ")"'s? ...

    >Why does this tell me i'm missing ")"'s?
    >sizeof wxString
    I think you need sizeof(wxString), only because wxString is a class, or you could also write sizeof billdat.Cost.

    >p.s. Will it work?...
  14. Replies
    9
    Views
    2,662

    Use tabstop's idea, and will probably...

    Use tabstop's idea, and <ENTER> will probably compare equal with either '\n' or '\r'.
  15. Replies
    8
    Views
    2,104

    >void main() And it's a good habit to return an...

    >void main()
    And it's a good habit to return an int from main, since void main() is wrong.

    int main(void)
    {
    .
    .
    return 0;
    }
  16. Replies
    8
    Views
    2,104

    >Can you please explain me why it wasn't k...

    >Can you please explain me why it wasn't k earlier...coz the pointer also would give the same size of the node.
    node is defined as a pointer to struct nodetype:

    typedef struct nodetype *node;
    ...
  17. Replies
    8
    Views
    2,104

    You might need to use the actual object: node...

    You might need to use the actual object:
    node tmp = malloc(sizeof(*tmp));
  18. Replies
    8
    Views
    2,104

    >node tmp=(node)malloc(sizeof(node)); Make this:...

    >node tmp=(node)malloc(sizeof(node));
    Make this:
    node tmp = malloc(sizeof(*node));

    You should also #include <stdlib.h> for malloc().
  19. Replies
    8
    Views
    2,104

    I'm not spotting any problem with your code. Try...

    I'm not spotting any problem with your code. Try traversing the tree after every insert(), and let us know what it prints for the tree:

    insert(&mytree, num);
    intrav(mytree);

    printf("\nEnter...
  20. Replies
    13
    Views
    2,493

    How much memory did you allocate for...

    How much memory did you allocate for screenDataPnt (or whatever buffer that points to)?
  21. Replies
    6
    Views
    1,345

    >open it as fopen("rb") instead of ("r") Correct.

    >open it as fopen("rb") instead of ("r")
    Correct.
  22. Replies
    6
    Views
    1,345

    >read the file in text (not binary) mode....

    >read the file in text (not binary) mode.
    Wouldn't it be the opposite?
  23. Replies
    11
    Views
    3,009

    Also I'm assuming you set *array to point to...

    Also I'm assuming you set *array to point to resizedarray at some point. And MacGyver makes a good point about & in front of tmp for the scanf().
  24. Replies
    11
    Views
    3,009

    >Also, shouldn't I free the original array...

    >Also, shouldn't I free the original array regardless and set it equal to resizedarray?
    No, because resizedarray may actually point to the exact same memory.

    I may be wrong about this, but I...
  25. Replies
    11
    Views
    3,009

    >do this mean I need to declare a new char ** and...

    >do this mean I need to declare a new char ** and set the realloc equal to it
    That's the preferred method, because in case realloc() returns NULL, you can still free the original before returning...
Results 1 to 25 of 497
Page 1 of 20 1 2 3 4