Search:

Type: Posts; User: eerok

Page 1 of 4 1 2 3 4

Search: Search took 0.01 seconds.

  1. Thread: linked list

    by eerok
    Replies
    5
    Views
    1,314

    The first problem I notice: you cast malloc(),...

    The first problem I notice: you cast malloc(), which suppresses the error you should receive for not including stdlib.h ...

    Even after fixing that, it still segfaults, so I'm looking at the rest...
  2. Thread: Pointer fear

    by eerok
    Replies
    6
    Views
    1,656

    This declares a string literal. Nothing wrong...

    This declares a string literal. Nothing wrong with that as long as you don't try to modify the string (you'll likely segfault if you do). If you don't want a string literal, you can assign the...
  3. Replies
    8
    Views
    1,530

    Also you want to pass "width" to printsquare() ...

    Also you want to pass "width" to printsquare()

    edit:

    You pass it to getwidth() but that isn't useful at all. If you declare "width" in getwidth() and return it, that's good enough; then you...
  4. Thread: loop

    by eerok
    Replies
    13
    Views
    1,679

    You said you didn't want the exact answer, so I...

    You said you didn't want the exact answer, so I didn't write your program for you.

    You can simply check the input inside the getchar() loop with isdigit() or whatever you like.
  5. Thread: loop

    by eerok
    Replies
    13
    Views
    1,679

    You can approximate fgets() with something like...

    You can approximate fgets() with something like the following:



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

    int
    main (void)
    {
  6. Replies
    8
    Views
    17,424

    You want something like this: int ch; ...

    You want something like this:



    int ch;
    ...
    while ((ch = fgetc (textfile)) != EOF) {/* do your thing */}


    You need to find a good reference so you can look up the standard functions...
  7. Replies
    5
    Views
    1,479

    > C doesn't have mixed declarations and...

    > C doesn't have mixed declarations and statements (C++ does)

    C99 supports this; there may be good reason at times for not relying on its implementation on a given compiler, but it's C.
  8. Thread: End Program

    by eerok
    Replies
    7
    Views
    2,339

    It's also unfortunate that "validate" is tested...

    It's also unfortunate that "validate" is tested when it's uninitialized.
  9. Replies
    8
    Views
    1,994

    I'm primarily a unix guy, but I believe conio.h...

    I'm primarily a unix guy, but I believe conio.h is a borland extension ... so it's not valid in more than just unix: it's not standard C at all

    You can use getchar() instead, which is in the FAQ
  10. The standard type for that is "ptrdiff_t" as...

    The standard type for that is "ptrdiff_t" as defined in stddef.h
  11. Thread: stat() printing

    by eerok
    Replies
    5
    Views
    1,296

    If you include "fstat" and/or "lstat" in your...

    If you include "fstat" and/or "lstat" in your google string, you should get one of the many webified man pages.
  12. Replies
    10
    Views
    5,584

    If you're using linux, google on LFS (large file...

    If you're using linux, google on LFS (large file support). You just need to compile with an extra flag or two with gcc in order to change off_t from 32- to 64-bit.
  13. Thread: Compilers

    by eerok
    Replies
    4
    Views
    991

    It's hard to know what's going on without seeing...

    It's hard to know what's going on without seeing the source.
  14. Replies
    2
    Views
    1,105

    Dot files are conventionally treated differently...

    Dot files are conventionally treated differently by unix utilities and apps, but as far as standard C functions are concerned, they're just files with filenames that start with a dot. They're not...
  15. Replies
    11
    Views
    1,178

    Like quzah says, you need to put a printf() loop...

    Like quzah says, you need to put a printf() loop inside the sort function, for example:



    #include <stdio.h>


    void sort (int a[], int n);

    int main (void)
  16. Thread: C or C++?

    by eerok
    Replies
    14
    Views
    1,578

    Hey, you forgot common lisp! ((((actually, I...

    Hey, you forgot common lisp!

    ((((actually, I hate all those parentheses))))
  17. Thread: Splint

    by eerok
    Replies
    24
    Views
    3,895

    Well, I installed splint just to see what you're...

    Well, I installed splint just to see what you're talking about. I ran it on code I've been working on today, and this is my favorite "warning" from splint ...



    sift2.c:104:11: Storage e->h3...
  18. Thread: C or C++?

    by eerok
    Replies
    14
    Views
    1,578

    That's a good enough answer to your question:...

    That's a good enough answer to your question: focus on what you're going to use.



    Well, I'm 51 (I'm expecting wisdom and maturity to overtake me Any Day Now ...)

    Anyway, if you spend time...
  19. Thread: Splint

    by eerok
    Replies
    24
    Views
    3,895

    I have to admit that my first reaction to a...

    I have to admit that my first reaction to a warning that suggests that I need a cast is to look to see what I did wrong. It's generally fixable without the cast, though this probably depends...
  20. Something like this will work better ...

    Something like this will work better



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

    /* arbitray value for testing purposes; perhaps too small
    * ... it would likely be better to malloc() a...
  21. I couldn't get an error from the code provided,...

    I couldn't get an error from the code provided, even executing it four times ...
  22. According to the standard, redefinition is...

    According to the standard, redefinition is allowed, though with constraints (6.10.3 item 2). gcc emits a warning with the following code, but it compiles.



    #include <stdio.h>

    #define X 2...
  23. Replies
    11
    Views
    1,347

    According to the standard, it's 0 or 1. I see...

    According to the standard, it's 0 or 1.

    I see your point, though ... it shouldn't really matter.
  24. Thread: string trouble

    by eerok
    Replies
    8
    Views
    1,280

    strchr() returns a pointer to the first...

    strchr() returns a pointer to the first occurrence of a char in a string, or NULL if the char isn't found. It's a very useful function for parsing text, and it's in the standard C library. You...
  25. Replies
    3
    Views
    2,315

    /* executable code above here */ int i = 0; ...

    /* executable code above here */
    int i = 0;

    This kind of declaration is allowed in C99 but not in previous versions of ansi C (or K&R C). This isn't really an issue unless you try to use a...
Results 1 to 25 of 91
Page 1 of 4 1 2 3 4