Search:

Type: Posts; User: pdc

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Thread: 64-bit quantaties

    by pdc
    Replies
    3
    Views
    1,131

    Answering my own question, it seems that int64_t...

    Answering my own question, it seems that int64_t is the correct choice, as of C99. Second question still stands, though.
  2. Thread: 64-bit quantaties

    by pdc
    Replies
    3
    Views
    1,131

    64-bit quantaties

    What's "best" type to use to guarantee a 64-bit quantity? I know it's implementation and platform dependent, but is their any sort of de facto standard? I've seen int64_t, __int64, int64...

    Also,...
  3. You want something like: #include ...

    You want something like:


    #include <stdio.h>
    #include <unistd.h>
    #define BUFSIZE 100

    int main(void) {
    char buf[BUFSIZE];
  4. Replies
    13
    Views
    3,517

    I'm aware of it, yeah, but it (thankfully!) seems...

    I'm aware of it, yeah, but it (thankfully!) seems pretty dead these days.
  5. Replies
    14
    Views
    6,823

    Sorry, yeah, Windows calls it _popen(). It has...

    Sorry, yeah, Windows calls it _popen(). It has much the same behaviour, except read-write mode is "rw" and not "r+".
  6. Replies
    14
    Views
    6,823

    popen() is standard, I don't think socketpair()...

    popen() is standard, I don't think socketpair() is available on Windows as it is on UNIX.
  7. Replies
    13
    Views
    3,517

    By all means, code in whatever style suits you...

    By all means, code in whatever style suits you best. Just remember that current styles have evolved because they generally prove to be most readable in the long-run, and that you're probably not...
  8. Replies
    14
    Views
    6,823

    AFAIK: popen() can create bidirectional pipes on...

    AFAIK: popen() can create bidirectional pipes on OS X and BSD, but only unidirectional on Linux and Solaris.
  9. Replies
    14
    Views
    6,823

    Use popen(), defined in stdio.h. For example, for...

    Use popen(), defined in stdio.h. For example, for cross platform sockets ;):

    #include <stdio.h>
    #define BUFSIZE 100

    int main(void) {
    char buf[BUFSIZE];

    FILE * f = popen("telnet...
  10. Replies
    27
    Views
    4,099

    All that code is valid C. Tell us what part of...

    All that code is valid C.

    Tell us what part of it you can't understand, and someone might try to help.
  11. Replies
    13
    Views
    3,517

    In general, C style is not to indent braces....

    In general, C style is not to indent braces. I.e., the above should be:

    #include <stdio.h>
    #include <conio.h>

    int main()
    {
    char c;
    long a = 0;
    while (a != -1)
  12. Thread: Link List

    by pdc
    Replies
    8
    Views
    1,309

    It should be: struct node { int x; struct...

    It should be:
    struct node {
    int x;
    struct node *next;
    };
    The original version could be made valid with an appropriate typedef.
  13. Replies
    13
    Views
    3,517

    If you're willing to use Cygwin it is, at least:...

    If you're willing to use Cygwin it is, at least:

    http://mir.zyrianes.net/cygwin/release/ncurses/
  14. Replies
    6
    Views
    18,989

    That's great, exactly what I was looking for,...

    That's great, exactly what I was looking for, thanks!
  15. Replies
    6
    Views
    18,989

    That doesn't work. As I said, representing them...

    That doesn't work. As I said, representing them isn't the problem. Reresenting them as a string literal is. Can they be written as "<something>"?
  16. Replies
    5
    Views
    1,830

    PS, you should look at rewriting a lot of your...

    PS, you should look at rewriting a lot of your code. For example, you have 11 lines of the form

    freq[0] = freq[0] + 1;
    These could be condensed to just one. Remember that an array subscript can...
  17. Replies
    5
    Views
    1,830

    Use atoi() and fgets(), both defined in stdio.h:...

    Use atoi() and fgets(), both defined in stdio.h:


    #include <stdio.h>
    #define BUFSIZE 5

    int main(int argc, char * * argv) {
    char buf[BUFSIZE]; //max of five digits
    printf("How many...
  18. Thread: Boolean data type

    by pdc
    Replies
    5
    Views
    18,874

    Yes, as of C99, but it's not a library. Just...

    Yes, as of C99, but it's not a library. Just include <stdbool.h>.


    #include <stdio.h>
    #include <stdbool.h>

    int main(int argc, char * * argv) {
    bool b = getc(stdin) == 't' ? true : false;...
  19. Replies
    4
    Views
    1,570

    What memory you allocated? The struct only...

    What memory you allocated? The struct only contains space for a pointer to a string, not the memory for the string itself. (It couldn't contain the memory for the string, not knowing how big it will...
  20. Replies
    13
    Views
    3,517

    Consider taking a look at curses, or ncurses,...

    Consider taking a look at curses, or ncurses, which is available for almost all UNIX-like OSs, and has a non-blocking getch() call:

    #include <ncurses.h> /* ncurses.h includes...
  21. Replies
    4
    Views
    1,570

    When you store a string's value somewhere else,...

    When you store a string's value somewhere else, you either mean copying the whole sequence, or just copying the address of the start of the sequence. The latter seems simplest here.

    In your case,...
  22. Replies
    6
    Views
    18,989

    I should probably add, since this is...

    I should probably add, since this is platform-dependent, that I'm using GCC on OS X and FreeBSD.
  23. Replies
    6
    Views
    18,989

    UTF-8 string literals

    What's the best way of embedding UTF-8 (specifically UTF-8, not Unicode) literals in strings in C? You can, of course, do them as byte (char) sequences, but that makes it impossible to write

    char...
  24. Replies
    3
    Views
    3,185

    Thanks, yeah, I just went with something similar...

    Thanks, yeah, I just went with something similar myself in the end. It was always going to be an opportunistic hack, nothing Dijkstra would approve of :)
  25. Replies
    3
    Views
    3,185

    Printing enum field symbolically

    For debugging purposes, is there any way of programatically retrieving the symbolic name of a field in an enum, rather than just printing its numeric value? I'm pretty sure there's no way in ANSI C,...
Results 1 to 25 of 28
Page 1 of 2 1 2