User Profile

Collapse

Profile Sidebar

Collapse
vmpstr
vmpstr
Last Activity: Nov 12 '09, 10:44 PM
Joined: Nov 18 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • vmpstr
    replied to Help with vectors
    in C
    Hmm... Thanks for explaining that, it makes a bit easier to think about definitions and declarations.

    :D
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to Help with vectors
    in C
    I've always been very week in my terminology. I apologize for that. I believe it's called "type definition". I'm referring to the chunk of code that is something along the lines of the following:

    Code:
    struct a
    {
        int i;
    };
    By "struct made global", I'm referring to the previous reply (by Ganon11) which suggested that the struct definition should be moved outside of the function....
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to Help with vectors
    in C
    It doesn't compile on g++ 4.2.4
    Making the struct definition global produces a different kind of error. But, if the struct is made global and the line
    vector <acct> accounts;
    is replaced with
    vector <struct acct> accounts;
    it compiles and links
    See more | Go to post

    Leave a comment:


  • This is MS-ism. Apparently, ^ is to signify a handle, which acts basically like a pointer, but is garbage collected (hence gcnew instead of new: gc stands for garbage collected).

    Given that it is garbage collected, it will be deleted for you once there are no more preferences to that address... hopefully.
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to Program received signal SIGBUS, Bus error.
    in C
    I see two (and a half) things that I would fix.

    The half is that half of your malloc returns are cast and have are not. Pick one (not casting malloc is the correct thing to do in C).

    Other than that,

    1. You might want to check if letter is negative before you index into an array using it. I'm referring to character-65 calculation. There are plenty of characters that will cause that expression to be negative....
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to Why won't my code append data to file
    in C
    Post your code please.

    It seems that the problem you have is you just read what you need, and then write it back to the file (overwriting much of everything else).

    What you need to have is to read all of the entries, modify the required ones, and write all entries back
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to can any one show me the proper path do this
    in C
    assuming that you allocate enough space to the char*, you can use sprintf in a loop

    you want to initialize your str to an empty string, and then keep printing to the end of it. You know the end of the string with either strlen or some calculation using sprintf's return code.

    In my opinion that would be as simple as any other approach
    See more | Go to post

    Leave a comment:


  • CodecSmash49
    CodecSmash49 posted a Visitor Message for vmpstr
    Is there a way I can contact you with more direct and faster messaging, such as AIM or MSN. The jump we made in this programming level has pretty much screwed me over.
    We went from basic enter a text to A.I and user real time input as well as moving object. I'm really baffled and could use some help, if you have time
    See more | Go to post

  • vmpstr
    replied to long double range
    in C
    Googling long double gets me to this article:
    Long double - Wikipedia, the free encyclopedia

    Reading about it, and narrowing it down to 128 bit long double, makes me click a link in that article to the following article:

    Quadruple precision - Wikipedia, the free encyclopedia

    That one describes how it is stored, it's ranges, and some examples. Finishing with the first article, I get the impression that...
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to Two compiling errors
    in C
    You are missing a semicolon after return 0. Also, for the future: it would be extremely helpful if you, aside from posting your code, also post the error you get.

    Typically, we are much better at understanding the error message than we are at just skimming the code and figuring out what's wrong.

    good luck! :D
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to cellular automata c++ help
    in C
    As Studlyami said, your ONOrOFF function just checks array[row-1][column]. It has the correct row > 0 check, but you also need to check other array positions.

    row < 9 && array[row+1][column]
    column > 0 && array[row][column-1]

    etc
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to cellular automata c++ help
    in C
    It looks pretty good so far, I mean... I think some variables are missing? Did you post the whole code? If so, does it compile?

    One note in the OFFOrON function: make sure you don't go outside of the boundary of the array. For instance, if row is 0, then arrayCells[row-1][column] will result in a segmentation fault. You should do something like:

    if ( (row > 0) && (arrayCells[row-1][column] == 1) )

    ...
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to std::set within std::map problem
    in C
    You have to add keyword typename before your definition of it.

    i.e.

    Code:
    typename map<T, set<string> >::iterator it;
    Why, you ask? I only vaguely understand that this helps the compiler understand that map<T, set<string> >::iterator is a type, not something else. Shouldn't it know it by itself? Well, no, because you put in a template parameter in there, which can be anything...
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to despertly need your help
    in C
    Post your changed code, please. (put [ CODE ] before it and [ /CODE ] after it (without spaces in between the brackets)
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to despertly need your help
    in C
    If you are a beginner, use a character array (like char array[50] instead of char *array).
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to how to convert decimal number to binary
    in C
    I prefer looping over the number of bits and doing a check along the lines of
    Code:
    if ( num & (1 << curbit) )
    If that is true, then bit curbit is set (the least significant bit being bit 0). This is very similar to what weaknessforcats said, except that one is

    Code:
    if ( (num >> curbit) & 1 )
    :D
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to despertly need your help
    in C
    It would help if you post what messages you are getting...

    Maybe you forgot to return 0 in main? Or maybe your version of strcmp return 1 when the strings are not equal, yet the if statement in your main implies that it returns 1 when they are equal?

    (and, of course, you don't allocate any memory to your pointers, as mentioned above)...
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to Videogame
    in C
    We're here to answer, so don't be sorry for asking.

    Umm... Well, from the code you have, I don't see a simple way out...

    you have function A and function B (A happens to be main)

    in A, you move the bar and call B
    in B, you move the thunder all the way down.

    So you see, you can't move the bar while the thunder is moving down, because the control isn't going to return to A until the thunder...
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to Videogame
    in C
    Suppose you only have one thunder at any point in time. Say you have thunderx and thundery for it's position and thunderexists as a flag meaning it exists (this should all be stored in a struct, if you have studied that)

    Then you can have something along these lines (and forgive me if it doesn't compile, I'm just typing it in, not testing it)

    Code:
    // infinite loop
    for(;;)
    {
       if(thunderexists == 0)
    ...
    See more | Go to post

    Leave a comment:


  • vmpstr
    replied to C an ATM
    in C
    You don't understand the concept of reading strings from file? What piece of code from your C book do you not understand in particular?
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...