Search:

Type: Posts; User: mnd22

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    9
    Views
    2,075

    Wow! Thank you for the link Subsonics. This will...

    Wow! Thank you for the link Subsonics. This will help me a lot.
  2. Replies
    9
    Views
    2,075

    @KCfromNC Thank you for the tip. I will...

    @KCfromNC
    Thank you for the tip. I will check how can I use that approach. Sorry I forgot to put the success return code I just pasted a small part of the code.

    Another question what are...
  3. Replies
    9
    Views
    2,075

    Still want to use C on this project just checking...

    Still want to use C on this project just checking if there is a better way to handle this. Since there's no better solution I will just leave it like that then.

    Thanks for the info.
  4. Replies
    9
    Views
    2,075

    Better way to free resources on error

    Is there a better way to handle this situation? Everytime I open a file and allocate memory I check if it is successful. If not then free all files and memory before I return an error.



    int...
  5. Thread: Remove a char

    by mnd22
    Replies
    14
    Views
    1,595

    :wink: lol told you its not tested but you got...

    :wink: lol told you its not tested but you got the idea.
  6. Thread: Remove a char

    by mnd22
    Replies
    14
    Views
    1,595

    You are getting double because you are passing...

    You are getting double because you are passing src which now points to '\0' after "he llo" when you pass it to strcpy which will result to "he llohello".
  7. Thread: Remove a char

    by mnd22
    Replies
    14
    Views
    1,595

    You don't actually need an extra char buffer. You...

    You don't actually need an extra char buffer. You can just re use src.



    void DelChar(char *src)
    {
    int i = 0;

    while (*(src) != '\0')
    {
  8. If you are aiming for high-performance then use...

    If you are aiming for high-performance then use Unrolled Linked Lists. It stores multiple elements in a single node which greatly improves cache usage and lesser memory usage when all nodes are full...
  9. Replies
    10
    Views
    1,189

    Did you check if you are getting hits on line...

    Did you check if you are getting hits on line 118?


    if((delta_energy<0)||(R<=exp(-delta_energy/Temp))) //Change spin state if delEnergy is less than 0 {
    ...
  10. Replies
    7
    Views
    1,937

    What happens when j = 25 and i = 1? Your...

    What happens when j = 25 and i = 1?

    Your printf will be:
    printf("%s", names[25][1]);

    That will be out of bounds of array names. switch your for loops not i and j.
  11. Replies
    3
    Views
    794

    Also take note that on line 25 you are trying to...

    Also take note that on line 25 you are trying to change the address of the array which will not work, think about array as a constant pointer you cannot modify it. Do what laserlight suggested pass...
  12. Yes after fread. Just before you do fwrite()....

    Yes after fread. Just before you do fwrite(). Post your updated code I am not sure how you did the changes.
  13. You are opening the file in a+b mode. When you...

    You are opening the file in a+b mode. When you save the changes it will append it at the end of the file not update the data. Try to do what vart said or open the file with "r+b" then fseek at...
  14. Here's a reference for fseek() fseek - C++...

    Here's a reference for fseek()
    fseek - C++ Reference

    use SEEK_SET with position 0 to put it at the beginning of the file.

    regarding the printf issue. You are storing the '\n' when you hit...
  15. Replies
    4
    Views
    1,198

    You can pass an char array from the calling...

    You can pass an char array from the calling function. Then store the response in there so you don't need to use malloc.

    So it will be like this. Just make sure that head and body will fit in...
  16. Remember that arrays used as a function parameter...

    Remember that arrays used as a function parameter are degraded to a pointer. In varfun stack is now *stack not stack[].

    Here's a link that explains this further:
    Question 6.21
  17. Replies
    15
    Views
    5,984

    My first thought is I don't think its actually...

    My first thought is I don't think its actually receiving the value of 'j'. I think its only writing at this address 'AddressWriteHT1632C(0x00);' have you tried changing it and see what happens?
  18. Since you already have the odd and even numbers...

    Since you already have the odd and even numbers separated on sort_array[]. You can use qsort() or any sort algorithm that you want and just pass the odd and even section of the array and the length...
  19. Replies
    6
    Views
    1,550

    Wow that works guys @@, thanks a lot!

    Wow that works guys @@, thanks a lot!
  20. Replies
    6
    Views
    1,550

    iMalc you are right I am casting char to a larger...

    iMalc you are right I am casting char to a larger int. I was hoping I can do this


    FILE *fp;
    fp = fopen("c:\\test.tst","wb");

    if(fp) {
    int pos = 500;
    char buf[8];
    ...
  21. Replies
    6
    Views
    1,550

    Help on fwrite() and fread() an int

    Can somebody help me. I am having problems storing a signed long int ('s64') to a file. For some reason when blob.pos is > 127 when I read it from the file it will return junk value.

    I think it...
  22. Replies
    5
    Views
    1,310

    Wow this is a great site laserlight! Thank you...

    Wow this is a great site laserlight! Thank you for the link!
  23. Thread: C code critique

    by mnd22
    Replies
    8
    Views
    1,825

    I kept on thinking about what you said last night...

    I kept on thinking about what you said last night and I just finally realized how it works while brushing my teeth this morning ;). Thank you very much that will help me a lot.

    @grumpy
    I wont...
  24. Thread: C code critique

    by mnd22
    Replies
    8
    Views
    1,825

    Thanks! That makes it more efficient. I did add...

    Thanks! That makes it more efficient. I did add an extra free so it will free dirPath on every code path.

    @whiteflags
    Can you explain further why do I need **FILE instead of *FILE? I cannot fully...
  25. Thread: C code critique

    by mnd22
    Replies
    8
    Views
    1,825

    C code critique

    I am still pretty new to C and I learned a lot from this forum. This is a working code (In windows by the way). I already learned that you don't have to cast the return of malloc. I am wondering if...
Results 1 to 25 of 52
Page 1 of 3 1 2 3