Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    6
    Views
    97

    Well... I try to use the "left hand side" rule...

    Well... I try to use the "left hand side" rule used in some C standard functions... As examples:


    // dest is the 'output'
    char *strcpy( char *dest, char *src );

    // 'buffer' is the 'output'...
  2. Replies
    6
    Views
    112

    Ok... your ONLY question: "What am I missing...

    Ok... your ONLY question: "What am I missing here?"
    A: I think you aren't missing anything...
  3. Replies
    6
    Views
    112

    Aren't you overthinking about pointers usage? ...

    Aren't you overthinking about pointers usage?

    // FIX: Returns true if OK, false if allocation fail.
    int push ( Node **head, int new_data )
    {
    Node *new_node = malloc ( sizeof ( Node ) );

    ...
  4. Replies
    2
    Views
    124

    // Assuming string is less then 33 chars long...

    // Assuming string is less then 33 chars long (excluding the '\0').
    // Assuming, also, each char is either '0' or '1'.
    unsigned int bin2int(char *str)
    {
    unsigned int n = 0;

    while ( *str )...
  5. Replies
    2
    Views
    115

    I believe C99 is the most popular nowadays, but...

    I believe C99 is the most popular nowadays, but compilers like GCC [version 7 or superior, I think] uses extended C11 by default (GNUC11).
  6. This doen't seem to be bubble sort, but insertion...

    This doen't seem to be bubble sort, but insertion sort...
    Insertion Sort
    Bubble Sort
  7. Thread: average

    by flp1969
    Replies
    1
    Views
    83

    Change line 20 to: printf( "%f\n", sr );...

    Change line 20 to:

    printf( "%f\n", sr );
    And line 38 to:

    return (double)wynik / n;
  8. Replies
    9
    Views
    200

    Seeing your code I assume you speak portuguese,...

    Seeing your code I assume you speak portuguese, right? I am brazillian and here's one article I wrote sometime ago:

    Deslocando uma string de bits.

    Maybe you adapt this to your needs.
  9. Assembly?

    Assembly?
  10. Replies
    9
    Views
    236

    Exactly! :)

    Exactly! :)
  11. Replies
    9
    Views
    236

    From IOCCC: /* ball.c */ /* Compile with:...

    From IOCCC:


    /* ball.c */
    /* Compile with: 'gcc -ansi -o ball ball.c -lm' */
    /* Works on linux */
    #include <stdio.h>
    #include <math.h>
    #include <unistd.h>
    #include <sys/ioctl.h>
  12. Replies
    3
    Views
    121

    Nope... this function returns 'n*alg', the...

    Nope... this function returns 'n*alg', the average is 'alg'.

    And... if n <= 0 (n is a signed integer!) it will return 'alg*((2łą - abs(n)) + 2łą-2)'.
  13. Is 'byte' a pointer? 'byte+1' isn't a lvalue and...

    Is 'byte' a pointer? 'byte+1' isn't a lvalue and will cause a compilation error... and you are using 'tmp' instead of 'temp', did you notice?
    What this code is supposed to do?
  14. Replies
    4
    Views
    143

    One example of what @Hodor probably meant by "By...

    One example of what @Hodor probably meant by "By using the volatile keyword you're telling the compiler to be very careful about assumptions it might otherwise make":

    int a;
    volatile int b;
    ...
  15. Well... Using 'int' to hold the number of seconds...

    Well... Using 'int' to hold the number of seconds is not that bad. Timestamps, for example, can hold the number of seconds since January 1st 1970 to 2038 using a 32 bits integer (time_t is...
  16. Replies
    17
    Views
    357

    Nooo... really?! ;)

    Nooo... really?! ;)
  17. Replies
    17
    Views
    357

    Hehhee: log xy = log x + log y log x/y = log...

    Hehhee:

    log xy = log x + log y
    log x/y = log x - log y
    log x^y = y * log x

    Simple as this... :)
  18. Replies
    7
    Views
    175

    Another one for your study: /* Compile with...

    Another one for your study:

    /* Compile with GCC:

    gcc -o test test.c

    Add -DDEBUG with you want to see 'debug' messages. */
    #define _GNU_SOURCE
    #include <stdlib.h>
    #include <stdio.h>
  19. Replies
    2
    Views
    158

    Depends on the compiler optimization. Could be on...

    Depends on the compiler optimization. Could be on registers.
  20. Replies
    14
    Views
    252

    If you want to initialize a bunch of elements of...

    If you want to initialize a bunch of elements of dynamically allocated array you can do as @Zeus_ told you:

    p[0] = 5;
    p[1] = 15;
    p[2] = 5;
    p[3] = 53;
    p[4] = 101;
    Or, in C (not C++), with a...
  21. Replies
    14
    Views
    252

    Use the operador [] or the operator *: int...

    Use the operador [] or the operator *:


    int *p;

    p = malloc( size * sizeof( int ) );
    for ( i = 0; i < size; i++ )
    p[i] = K; // OR *(p + i) = k;
  22. Replies
    14
    Views
    252

    See? Very easy to spot, isn't it? Now some...

    See? Very easy to spot, isn't it?
    Now some considerations:

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

    int main( void )
    {
    // You don't need to use type casting here, malloc() will return a...
  23. Replies
    14
    Views
    252

    Well, yeah, but there is a another error... look...

    Well, yeah, but there is a another error... look closer... a little longer...
  24. Replies
    14
    Views
    252

    Take a good look at your printf() calls...

    Take a good look at your printf() calls...
  25. Replies
    14
    Views
    252

    1st- You are not allocating "one" integer, but 5...

    1st- You are not allocating "one" integer, but 5
    2nd- You are printf the same variable (i)
    3rd- You are getting warnings from your compiler and not paying attention to them.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4