Search:

Type: Posts; User: HolmesChang

Search: Search took 0.01 seconds.

  1. Replies
    6
    Views
    1,251

    Hello~ I do use malloc to allocate array...

    Hello~

    I do use malloc to allocate array dynamically, which is to assign the number of unit cell(sizeof(unsigned int)) of the memory space corresponding to the element number in a sequence.

    And...
  2. Replies
    6
    Views
    1,251

    Is it incorrect even if I let user input non-zero...

    Is it incorrect even if I let user input non-zero n with a following scanf in while()?

    So I shouldn't semi-dynamically assign the size of LoS[n] with an initialized 0 then change it afterward?
    ...
  3. Replies
    6
    Views
    1,251

    Sorry for the bothering. I did the function...

    Sorry for the bothering.

    I did the function desired.



    #include <stdio.h>
    #include <memory.h>
  4. Replies
    6
    Views
    1,251

    Excuse me. Besides the "segmentation fault"...

    Excuse me.

    Besides the "segmentation fault" error, I have another different question.

    I dynamically assign the number of interested sequence of fixed 4 elements in this code.

    If I want to...
  5. Replies
    6
    Views
    1,251

    A program calculating sequence

    Hello

    I did a on-line judge problem and the error msg is "segmentation fault"

    But the code goes well in my NB, using DEV-C++ 4.9.9.2.

    Could somebody give me some hints?

    Thanks a lot!
  6. I think it's the point to which I didn't know...

    I think it's the point to which I didn't know before.
    Now I know it.
    Thank you so much.
  7. Thank you. I read the usage of fflush from a...

    Thank you.

    I read the usage of fflush from a sample code of a textbook.
    It talks about how to escape from reading the unwanted \n after getchar();
    It also use a following getchar() to "absorb"...
  8. Replies
    13
    Views
    1,228

    I have tried %p and compared the output with that...

    I have tried %p and compared the output with that using %d.
    With %p, address in hex format is returned while decimal format with %d.
    However, it can't match the output using %p as I tried to...
  9. I think I might figure out why it still output...

    I think I might figure out why it still output unexpectedly.
    After calling scanf, I input y and pressed enter which is recognized as a character.
    scanf in the first loop read y and leave \n in the...
  10. Replies
    13
    Views
    1,228

    Thanks for your hint. I think I realize the...

    Thanks for your hint.
    I think I realize the cause of the problem.
    pc++ equals to pc = pc+1, changing the memory address of pc.
    Its a very basic mistake and I neglect it



    You pointed it out...
  11. Replies
    13
    Views
    1,228

    Hello I checked the output again and found...

    Hello

    I checked the output again and found that the memory address pointed to had been changed without expectation.
    I checked by the following code.




    #include <stdio.h>
    #include...
  12. Replies
    13
    Views
    1,228

    Thank you! I found this mistake and corrected...

    Thank you!

    I found this mistake and corrected it but still with some problems.
  13. Replies
    13
    Views
    1,228

    Thanks! I changed the request size of memory...

    Thanks!

    I changed the request size of memory in line 26, n=n+3.
    realloc allocates new memory space. Is it necessary to request a different size?
  14. Replies
    13
    Views
    1,228

    ...

    I am not sure about what you mean change pc. Do you mean change the value, the type or the memory it points to?
    I did change the value of pc after declaring and initiating NULL. I didn't change its...
  15. Replies
    13
    Views
    1,228

    Dynamic memory allocation problem

    I am now entering the part of memory management.

    As learning from some resources, realloc copies the content pointed by a declared pointer, frees its memory and then allocates a new memory space...
  16. Thank you so much!

    Thank you so much!
  17. Thanks a lot! Another problem raised is while...

    Thanks a lot!

    Another problem raised is while loop breaks in the 2nd run as I use %c in replace of %s.

    I can input the value of char variable using scanf with %c outside loop block without any...
  18. The variable is unexpectedly set zero while running while loop

    Hello, I am a new learner of C.

    I ran into a problem while using while loop.

    The declared and initiated local int variable works well with its specified value while running through the 1st run...
Results 1 to 18 of 18