Search:

Type: Posts; User: Banana Man

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    3
    Views
    1,230

    fscanf works better for reading words. while...

    fscanf works better for reading words.


    while ( fscanf(myfile, "%s", entry) == 1 )
    {
    printf("%s\n", entry);
    }
  2. It's not good coding if you only want the format...

    It's not good coding if you only want the format "(ddd) ddd-dddd". strtok allows stuff like "-ddddd-d(ddd)". I don't think strtok is the best function for an exact format. sscanf would work better.
    ...
  3. The only thing you can do is figure out how to...

    The only thing you can do is figure out how to draw stuff on the calculator manually. I don't know anything about your hardware, so you're on your own with that. :(
  4. Replies
    13
    Views
    1,640

    I don't, sorry. Can you make a small and complete...

    I don't, sorry. Can you make a small and complete program that crashes? That way I can run it and play with it under the debugger.
  5. Replies
    7
    Views
    1,400

    I was told that main() is the old style and might...

    I was told that main() is the old style and might cause problems, but main(void) is newer and unambiguous. I don't know any details though. :(
  6. You need to have a library that lets you write to...

    You need to have a library that lets you write to arbitrary locations on the screen, and the standard library doesn't do that. Try pdcurses.
  7. Replies
    13
    Views
    1,640

    What does your code look like? I'd guess that...

    What does your code look like? I'd guess that you're accidentally freeing memory twice.
  8. Replies
    15
    Views
    10,382

    It doesn't matter what your data is because it's...

    It doesn't matter what your data is because it's always going to be a list of bytes. If it's not text, you have to pass the number of bytes in the data, but it still works fine.


    int main(void)...
  9. Replies
    15
    Views
    10,382

    If you want to write to more than one...

    If you want to write to more than one destination, you have to use more than one stream. A good way to do that is passing around an array of file pointers and looping over it each time you want to...
  10. Replies
    1
    Views
    1,000

    Set the fill for cout to be whatever character...

    Set the fill for cout to be whatever character you want. Then when you have a width longer than the length of the value, empty space will be repaced with that character.


    #include <iomanip>...
  11. Replies
    19
    Views
    10,238

    You want a random float in a range using the code...

    You want a random float in a range using the code from that link? I'm not sure what all that stuff is for, but this works and uses code I pinched from the page. Don't ask me how it works though....
  12. Replies
    4
    Views
    1,352

    It works the same way as if you used variables. ...

    It works the same way as if you used variables.


    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
    // Define all of the output strings
    const char *originalMsg = "The original...
  13. Replies
    2
    Views
    1,323

    If you want hours and charge on the same line,...

    If you want hours and charge on the same line, why don't you just print them both on the same line? An input prompt also makes it easier to tell between input and output.


    printf("> ");...
  14. Replies
    5
    Views
    2,311

    Every value is made up of a bit pattern and a...

    Every value is made up of a bit pattern and a type. The bit pattern doesn't change, but just a bit pattern isn't useful. The type tells C how to represent the bit pattern. An example is that the bit...
  15. I take everyone's opinion seriously. I can't...

    I take everyone's opinion seriously. I can't learn if I don't.

    I guess it does seem like that with the straw man you've built up. I'm saying that in my program there was no need to free the memory...
  16. Sorry, but I don't want to take over this thread...

    Sorry, but I don't want to take over this thread until desmond5 says the original question is answered. I also think that you're not going to take any of my opinions seriously, so explaining them to...
  17. Yeah, but who dictates what best practices are? ...

    Yeah, but who dictates what best practices are?

    I thought "best practice" was not to use C99. :rolleyes:
  18. Because I relied on an "optimization" it means I...

    Because I relied on an "optimization" it means I was being sloppy? :rolleyes:

    I doubt it, but you can believe whatever you want to.
  19. I'm sure you have my best interests at heart and...

    I'm sure you have my best interests at heart and weren't just trying to be a know it all, so thanks for the nitpick. Anyway, my OS will free memory when the program ends and there's no point being...
  20. Replies
    12
    Views
    2,533

    It doesn't work like that. You can't set the size...

    It doesn't work like that. You can't set the size of an array at runtime unless you manage the array manually with pointers or use a vector object instead of an array.
  21. Replies
    12
    Views
    2,533

    Pass it the same way you declare it. void...

    Pass it the same way you declare it.


    void manage_table (int table[10][10]) {
    table[x][y] = z;
    }

    int main () {
    int table[10][10];
    manage_table (table);
  22. You can do it like this. #include ...

    You can do it like this.


    #include <stdio.h>
    #include <string.h>

    typedef struct
    {
    char *name;
    char **keys;
  23. > shifts bits right. ...

    << shifts bits left and >> shifts bits right.

    00000001 left shifted by 3 is 00001000. 00001000 right shifted by 3 is back to 00000001. But make sure that you only shift by a nonnegative amount and...
  24. Replies
    13
    Views
    1,445

    What does this program print? #include...

    What does this program print?


    #include <stdio.h>

    struct a
    {
    double b;
    double c;
    int d;
  25. Replies
    13
    Views
    1,445

    Yes, and you don't need the extra curly brackets....

    Yes, and you don't need the extra curly brackets.


    struct a array[2][2] = {0};
Results 1 to 25 of 58
Page 1 of 3 1 2 3