Search:

Type: Posts; User: l0cke

Search: Search took 0.01 seconds.

  1. Thread: File I/O program

    by l0cke
    Replies
    9
    Views
    1,017

    You're not including for your str*...

    You're not including <string.h> for your str* functions and memset. Also, refer here for why using !feof(fp) in a loop is wrong.
  2. Replies
    3
    Views
    1,649

    You can use chdir() to change directories. If you...

    You can use chdir() to change directories. If you don't want to hardcode in the directory, you can have it take it in as an command line argument.
  3. Replies
    4
    Views
    1,256

    For *nix based systems you can use ncurses or...

    For *nix based systems you can use ncurses or curses. I'm not sure about Windows though.

    You can google plenty of ncurses tutorials and you can check out the source code for rogue-like games.
  4. Thread: Scanf()

    by l0cke
    Replies
    9
    Views
    2,048

    printf("%u in octal is: %o\n", b, b); /* try this...

    printf("%u in octal is: %o\n", b, b); /* try this instead */
  5. Thread: puts( );

    by l0cke
    Replies
    9
    Views
    1,841

    puts() also prints the new line character at the...

    puts() also prints the new line character at the end for you. So you could type:

    puts("hello world!");
    instead of

    printf("hello world!\n");
  6. Thread: Scanf()

    by l0cke
    Replies
    9
    Views
    2,048

    There is a bettter link in the post below. You...

    There is a bettter link in the post below.

    You can use %u with scanf()/printf() to read/print an unsigned int(assuming you know a little bit about scanf()/printf()).
  7. Thread: help on program

    by l0cke
    Replies
    31
    Views
    2,741

    Your assignment is to print "Press any key!"...

    Your assignment is to print "Press any key!" INCLUDING the quotes.

    printf("Press any key!\n"); /* outputs: Press any key! */
    /* however */
    printf("\"Press any key!\"\n"); /* outputs: "Press any...
  8. Replies
    7
    Views
    1,319

    Didn't know that snprint wasn't portable. I also...

    Didn't know that snprint wasn't portable. I also figured that it's better to use to prevent a buffer overflow.
  9. Replies
    7
    Views
    1,319

    int num = 12345; char string[6];...

    int num = 12345;
    char string[6];
    snprintf(string, 6 ,"%d", num);
  10. Replies
    20
    Views
    70,387

    i is set to the last index number + 1, that's why...

    i is set to the last index number + 1, that's why the return is return stack[--i], so it subtracts 1 from i before it returns it.
  11. Replies
    20
    Views
    70,387

    int top(void) { int i; for(i = 0;...

    int top(void)
    {
    int i;
    for(i = 0; stack[i] != '\0'; i++)
    ;

    return stack[--i];
    }
  12. Replies
    20
    Views
    70,387

    What is stack declared as? Is it an int, char,...

    What is stack declared as? Is it an int, char, etc?
  13. Thread: Floppy Drive

    by l0cke
    Replies
    7
    Views
    1,093

    Could you specify the OS? If it's a *nix based...

    Could you specify the OS?

    If it's a *nix based OS you could change the permissions on /dev/fd0(*BSD's floppy device) to not allow writing.
  14. Replies
    23
    Views
    18,693

    It's back to a readable size, thanks.

    It's back to a readable size, thanks.
  15. Replies
    23
    Views
    18,693

    It's not the line length, it's the size of the...

    It's not the line length, it's the size of the font.
  16. Replies
    13
    Views
    1,387

    You forgot to remove the '\n' from fgets(). Some...

    You forgot to remove the '\n' from fgets(). Some people will also say scanf() is bad to use, so I suggest to use fgets() again.
  17. Replies
    4
    Views
    2,922

    http://gcc.gnu.org/faq.html ...

    http://gcc.gnu.org/faq.html
    http://gcc.gnu.org/readings.html
  18. Thread: C99 mode??

    by l0cke
    Replies
    3
    Views
    6,953

    It's giving you that error because you're...

    It's giving you that error because you're delcaring a variable inside the for loop, which is not part of the C99 standard(I think).
  19. Replies
    3
    Views
    880

    10257 -- 4 10258 -- 5 10257 -- 4 This should...

    10257 -- 4
    10258 -- 5
    10257 -- 4
    This should be:

    10257 -- 9
    10258 -- 6
    10257 -- 4

    (p + 1) will print the address of p[1], because you're incrementing where it points to, not what it points...
  20. Thread: help on program

    by l0cke
    Replies
    31
    Views
    2,741

    You forgot something: printf(""Press any...

    You forgot something:


    printf("\"Press any key!\"\n");

    Like \n, \"(that prints a ") is an escape sequence
  21. Replies
    16
    Views
    3,064

    if(10 = num) If you do that, you will get an...

    if(10 = num)
    If you do that, you will get an error at compile time. Which can save you from code that does unexpected things.

    If(num = 10)
    Will not give you a compile time error, which will not...
  22. Replies
    13
    Views
    1,387

    if((fp = fopen("&s" ,username, "r")) == NULL)...

    if((fp = fopen("&s" ,username, "r")) == NULL)
    perror("%s" ,username);
    fopen() only opens the file for reading, it doesn't do any reading itself. The arguments for fopen "&s", username will not do...
  23. Replies
    13
    Views
    1,387

    /* proper use for fopen */ FILE *fp; /* file...

    /* proper use for fopen */
    FILE *fp; /* file descriptor */
    if((fp = fopen("passwordfile.txt", "r")) == NULL) /* open for path for reading, check for errors */
    perror("passwordfile.txt"), exit(1);...
  24. Replies
    13
    Views
    1,387

    You're also using the wrong syntax for fgets and...

    You're also using the wrong syntax for fgets and fopen. I don't see any declaration for password and pass. Also, what is the point of the declaration char *fp, if you're not going to use it.

    What...
Results 1 to 24 of 25