Search:

Type: Posts; User: zub

Page 1 of 5 1 2 3 4

Search: Search took 0.01 seconds.

  1. Thread: C or Python?

    by zub
    Replies
    39
    Views
    2,372

    (Forth || Factor) && (Scheme || Lisp). :) If the...

    (Forth || Factor) && (Scheme || Lisp). :) If the choice between C and Python only, then certainly C. Its main advantage lies in the fact that it is low-level. When you need something high-level, you...
  2. Thread: confused :(

    by zub
    Replies
    6
    Views
    532

    while( fscanf(fp, "%s", str) == 1 ) { if(...

    while( fscanf(fp, "%s", str) == 1 ) {
    if( strcmpi(string, str) == 0 ) {
    found = 1;
    break;
    }
    }
  3. Thread: confused :(

    by zub
    Replies
    6
    Views
    532

    Why "found" uninitialized? Why it is compared in...

    Why "found" uninitialized? Why it is compared in such strange way: <= 1?
  4. Replies
    13
    Views
    884

    You can use more readable variation of same loop:...

    You can use more readable variation of same loop:



    while( 1 ) {
    c = getchar();
    if( c == EOF || c == '\n' ) { break; }
    text[n] = c;
    ++n;
    }
  5. Replies
    16
    Views
    983

    Hint: Changing the order of factors does not...

    Hint: Changing the order of factors does not change their product. So, you can calculate 1 x 2 x 3 x ...

    P.S. I recommend Sublime Text 2 (commercial editor, but it's trial period is eternal) and...
  6. Replies
    6
    Views
    504

    I do not understand the meaning of such learning....

    I do not understand the meaning of such learning. C language is not easy. Yes, it is a small language, but it has his own idiom, its programming techniques developed over many years. In a few months...
  7. Sieve of Eratosthenes - Wikipedia, the free...

    Sieve of Eratosthenes - Wikipedia, the free encyclopedia
  8. Replies
    4
    Views
    522

    1. Global variables are bad thing. Variable "o"...

    1. Global variables are bad thing. Variable "o" must be declared inside main() function;
    2. Names "o", "O", "l" (little L), "I" (big i) are very bad. I hope, reason is obvious.
    3. Mathematical...
  9. A few clarifications: I use Windows and Tiny C...

    A few clarifications: I use Windows and Tiny C Compiler. Most comfortable for me the following options:

    1. Library is a source code that can easily be included (a vivid example is SGLIB, it...
  10. Library for data manipulation (similar to STL in C++)

    In the book "97 things every programmer should know" said that the invention of bicycles can be useful. So we know how it works, and gaining experience. That's fine, but I've reached the stage where...
  11. Split program to little parts and test each of...

    Split program to little parts and test each of them independently - C Testing for Embedded Applications with greatest

    For example, this is simple function, that fills array with numbers, extracted...
  12. Replies
    3
    Views
    1,758

    Just add check for door state too: opened or...

    Just add check for door state too: opened or closed. It must be first check, because it does not make sense to check whether or not to close the closed door, and whether it is necessary to open the...
  13. Replies
    6
    Views
    768

    void remove_spaces(char* dst, const char* src) {...

    void remove_spaces(char* dst, const char* src)
    {
    int previous_symbol_was_space = 0;
    int c;
    while( c = (unsigned char) *src++ ) {
    if( previous_symbol_was_space && c == ' ' ) {...
  14. Replies
    4
    Views
    690

    Run program in command line.

    Run program in command line.
  15. Thread: using isspace

    by zub
    Replies
    13
    Views
    1,510

    You needn't set '\0' multiple times. You needn't...

    You needn't set '\0' multiple times. You needn't "return;". By the way, what happend, if string have no spaces at all? I advice you to use unit testing framework, for example greatest. Correct...
  16. Replies
    7
    Views
    867

    Yes, I misunderstood the task. I thought...

    Yes, I misunderstood the task. I thought topicstarter come from a country where the decimal point is written with a comma (as in Russia).
  17. Thread: Queues

    by zub
    Replies
    12
    Views
    889

    Tip: Create a dummy element in each list. It...

    Tip: Create a dummy element in each list. It point to the first element. This greatly simplifies inserting and deleting. For example, to insert an element at the beginning of the list, we just insert...
  18. Thread: Need help...

    by zub
    Replies
    6
    Views
    709

    Rewrite your code in testable way. For example: ...

    Rewrite your code in testable way. For example:



    float getHeight(const float ft, const float in)
    {
    return 0.3048 * ft + 0.0254 * in;
    }
  19. Replies
    7
    Views
    867

    #include "greatest.h" char* third_column(char*...

    #include "greatest.h"

    char* third_column(char* str)
    {
    char* ret = NULL;
    int space = 0;
    while( *str ) {
    space += *str == ' ';
    switch( space ) {
    case 2:
  20. Replies
    7
    Views
    867

    char* third_column(char* str) { char* ret =...

    char* third_column(char* str)
    {
    char* ret = NULL;
    int space = 0;
    while( *str ) {
    space += *str == ' ';
    switch( space ) {
    case 2:
    if(...
  21. It is very convenient. The fact that I make...

    It is very convenient. The fact that I make mistakes in this approach is due to my perfectionism (I scatter consts everywhere, necessary and not necessary). This does not mean that this technique...
  22. Thread: Append to strings

    by zub
    Replies
    13
    Views
    1,554

    I advise you to look at the source code of the...

    I advise you to look at the source code of the unit-testing framework CuTest. About half of it takes a framework for working with strings of arbitrary length (CuString). It is a very convenient...
  23. Replies
    2
    Views
    597

    Your program is just one big plate of spaghetti....

    Your program is just one big plate of spaghetti. Split program to little, obvious pieces. For example:


    typedef struct node node;

    node* new_node(node* const previous, const int new_data)
    {
    ...
  24. Thank you for being enlightened, you are...

    Thank you for being enlightened, you are certainly right about my assumptions. I do not know much yet in such nuances.



    I think this style have rights to exist in some kinds of programs....
  25. Replies
    51
    Views
    3,452

    /* My variation of Bernstein algorithm: 1....

    /* My variation of Bernstein algorithm:
    1. Perfect hashing for a string consist of no more than 6 symbols of the same type.
    For example, alphabetic only or numeric only, but not alphanumeric....
Results 1 to 25 of 104
Page 1 of 5 1 2 3 4