Search:

Type: Posts; User: Silfer

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    5
    Views
    1,189

    Keep in mind that functional languages use...

    Keep in mind that functional languages use recursion for "everything". Keep also in mind that sometimes finding the iterative algorithm is very difficult.
  2. Aha - thank you.

    Aha - thank you.
  3. How can it happen that they are not null when you...

    How can it happen that they are not null when you have just declared a new struct? As in,
    struct foo bar = malloc(sizeof(struct foo));
  4. Replies
    7
    Views
    1,611

    Err.. wait. I am not 100% sure here, for my...

    Err.. wait. I am not 100% sure here, for my memory of recursion is rusty. However, only your outermost call will return. It returns to the call that called it. You don't save that value, and it is...
  5. Thread: Recursion help

    by Silfer
    Replies
    11
    Views
    2,243

    I don't know what you are talking about, your...

    I don't know what you are talking about, your code from above works fine for me. Kill the if-else, and it is working, displayin correct results for values under 20 too.
  6. Replies
    2
    Views
    1,082

    I don't see you trying to exit the checkGuess()...

    I don't see you trying to exit the checkGuess() function anywhere in the function. If you want the function to exit somewhere, you can simply write
    return; If you want to exit a loop, you write
    ...
  7. Replies
    14
    Views
    2,425

    Which means, in effect, that you need what is...

    Which means, in effect, that you need what is called modulo maths, which is maths modulo number of letters in your alphabet. Formula for shifting one letter:

    result = c - offset + shift mod(%)...
  8. Replies
    3
    Views
    3,075

    Yes indeed, fflush() is undefined on input...

    Yes indeed, fflush() is undefined on input buffers.

    But I don't entirely see where you would need many if-elses in the case of a strike. You should tell us what you intent to happen after a...
  9. Replies
    9
    Views
    2,725

    int i; char* arrays[argc]; for (i = 1; i

    int i;
    char* arrays[argc];
    for (i = 1; i < argc; i++) {//i = 1 because argv[0] is program name.
    argc[i] = malloc(atoi(argv[i]));
    //check that malloc worked.
    }

    Or something similar.
  10. Replies
    18
    Views
    4,755

    fscanf() returns the number of items read and...

    fscanf() returns the number of items read and assigned, or EOF.

    Thus, your line


    salary += fscanf( input, "%f", &salary );

    Does not do what you want. I am not sure what it does, but you'll...
  11. Thread: help needed

    by Silfer
    Replies
    5
    Views
    7,900

    1. s2 and S2 are not the same, C is case...

    1. s2 and S2 are not the same, C is case sensitive.
    2. s1 is a variable name, "s1" is the string of two characters 's' and '1' with a \0 at the end.
    3. strcmp() returns a value that tells you...
  12. Thread: Hi people.

    by Silfer
    Replies
    10
    Views
    1,356

    I would recommend a code-like text editor (Vim,...

    I would recommend a code-like text editor (Vim, Emacs) and mayhaps a book - I personally love my K&R (The C programming language, by Kernighan and Ritchie). It has exercises in it.
  13. Replies
    11
    Views
    1,899

    The code does the same thing with formatting,...

    The code does the same thing with formatting, yes, but it is readable. If Istart wrting lk th is, and persist at it for a long time, would you care to read my post? Neither would we.
  14. Thread: Searching In C

    by Silfer
    Replies
    12
    Views
    1,484

    Well, if he actually wrote "return = 0;" in his...

    Well, if he actually wrote "return = 0;" in his code, I can understand that it didn't work ;)
  15. Replies
    11
    Views
    1,899

    Well, adding a comma - just print it after each...

    Well, adding a comma - just print it after each number.

    this:
    printf("%02d ", bytes[i] & 0xff);

    becomes:
    printf("%02d, ", bytes[i] & 0xff);

    and as for printing to a file, open the file in...
  16. Thread: help needed

    by Silfer
    Replies
    5
    Views
    7,900

    Well, strcmp() does what your number 1 should,...

    Well, strcmp() does what your number 1 should, more or less, altho I suppose you should implement it "from scratch". You should google the ascii table - chars in C follow it. Hint nr. 2: Chars are...
  17. Replies
    18
    Views
    4,755

    Oh, of course, you don't need an array - silly...

    Oh, of course, you don't need an array - silly me.

    fscanf does not care for spaces if you ask it to read numbers, btw, so you would only need to read a char twice to kill the two commas.
  18. Replies
    18
    Views
    4,755

    fscanf seems the obvious choice. Read one int,...

    fscanf seems the obvious choice. Read one int, the read one char to get rid of the comma, then read the second int, and read a char again to kill off the comma.

    Then, read one and one float and...
  19. Replies
    4
    Views
    1,416

    I am not sure about saving it in the environment,...

    I am not sure about saving it in the environment, as in in your shell. However, you can print it to stdout, and let b.c read from stdin. Then, you can pipe the output of a to stdin for b, with the...
  20. Thread: code problem

    by Silfer
    Replies
    1
    Views
    1,458

    Why can't you remove it after thread_switch()?

    Why can't you remove it after thread_switch()?
  21. Replies
    1
    Views
    885

    Why not simply read the five scores from the file...

    Why not simply read the five scores from the file into memory, preform calculations, and overwrite the file with the new scores? of course, if the score for player X hasn't changed, you'll be...
  22. Thread: Eof

    by Silfer
    Replies
    3
    Views
    1,201

    In most cases you won't have multiline input from...

    In most cases you won't have multiline input from the command line, but from a file, and there you don't hit enter to input, obviously, and can read till you find EOF.

    As for allowing the user to...
  23. Replies
    2
    Views
    1,084

    Too little information. Can you provide a code...

    Too little information. Can you provide a code snippet?
  24. Replies
    9
    Views
    3,283

    Oh, and also, when you read the numbers, you are...

    Oh, and also, when you read the numbers, you are not storing them in the array currently - you should if you want to keep them and want to find the highest/lowest.
  25. Replies
    9
    Views
    3,283

    Arrays in C can be declared like this: type...

    Arrays in C can be declared like this: type name[size];

    So you would want a float array[12];

    the keyword new does not exist in C - your Java days are over, and yes, it is a hard transfer.
    ...
Results 1 to 25 of 31
Page 1 of 2 1 2