Search:

Type: Posts; User: roaan

Page 1 of 13 1 2 3 4

Search: Search took 0.01 seconds.

  1. Thread: freopen....

    by roaan
    Replies
    7
    Views
    4,162

    Okay If I understand then I should be doing...

    Okay If I understand then I should be doing probably this.



    int main(){

    freopen("err.txt","w", stderr);
    FILE* input = freopen("member.d", "r", stdin);
    FILE* output = freopen("log.txt",...
  2. Thread: freopen....

    by roaan
    Replies
    7
    Views
    4,162

    Oops actually I made a mistake while posting the...

    Oops actually I made a mistake while posting the code segment. Here is the code segment that I am using.



    int main(){

    freopen("member.d", "r", stdin);
    freopen("log.txt", "w", stdout);...
  3. Thread: freopen....

    by roaan
    Replies
    7
    Views
    4,162

    freopen....

    I had a program which accepted input file on the command line and redirected output to file specified in the command line. So it was essentially



    $ ./name_of_program <input_file >output_file
    ...
  4. A couple of things more: 1. In the code you...

    A couple of things more:

    1. In the code you say that your main returns an int, but you are not returning anything from it. So make sure you return an int from the main.

    2. The fpurge() function...
  5. Thread: integers... help

    by roaan
    Replies
    3
    Views
    1,139

    I dont see the output as negative integer....

    I dont see the output as negative integer....
  6. Thread: malloc alignment

    by roaan
    Replies
    10
    Views
    2,037

    Extra work for me Now i have to understand this...

    Extra work for me Now i have to understand this as well :) (Just kidding) Let me go through it and ill also try to come up with something unique of my own.
  7. Thread: malloc alignment

    by roaan
    Replies
    10
    Views
    2,037

    Thanks, now i can explain that to anyone :-).

    Thanks, now i can explain that to anyone :-).
  8. Thread: malloc alignment

    by roaan
    Replies
    10
    Views
    2,037

    Any insights ?

    Any insights ?
  9. Thread: malloc alignment

    by roaan
    Replies
    10
    Views
    2,037

    [insert] void aligned_free(void *ptr) { ...

    [insert]

    void aligned_free(void *ptr) {

    int *ptr2=(int *)ptr - 1;
    ptr = (int *)ptr - *ptr2;
    free(ptr);
    }
  10. Thread: malloc alignment

    by roaan
    Replies
    10
    Views
    2,037

    Yes that makes it a lot clearer. So if instead i...

    Yes that makes it a lot clearer. So if instead i wish to have a alignment on a 16 bit boundary all those parameters would change accordingly. But another of the questions is that when i am trying to...
  11. Thread: malloc alignment

    by roaan
    Replies
    10
    Views
    2,037

    malloc alignment

    I have been tinkering around with this program but i am still unable to understand it. This is supposed to allocate memory returned my malloc and align it to a 4 byte boundary. I got this from the ...
  12. Replies
    1
    Views
    667

    malloc related query

    I just came across this question and wanted to know that does the malloc only allocate memory in multiples of 2 ? So if i want to have a memory say for my case i want memory in multiples of 32 should...
  13. Replies
    2
    Views
    1,375

    Checking if the two linked lists merge

    I wanted to know how do i check if the two linked lists merge. What should be the algorithm for this. I can only imagine that if the two linked lists merge then they will have a Y LIKE structure with...
  14. Replies
    4
    Views
    6,081

    bit representation of negative numbers

    I was doing some bit operations and when i try to get the bit representation of a negative number say -1 on my Intel processor the value that i get is

    11111111111111111111111111111111

    I had...
  15. Replies
    1
    Views
    845

    why am i not getting correct output

    I have written this program for the endian conversion but i am getting incorrect output. I am still unable to understand why?

    [insert]

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

    int main(void)...
  16. Thread: inline usage

    by roaan
    Replies
    2
    Views
    764

    inline usage

    I came across this code for doing the endian conversion.

    [insert]

    inline void endian_swap(unsigned short& x)
    {
    x = (x>>8) |
    (x<<8);
    }
  17. Replies
    16
    Views
    4,427

    Now it works. :cool:

    Now it works. :cool:
  18. Replies
    16
    Views
    4,427

    Yes i did that of putting a printf and i...

    Yes i did that of putting a printf and i understood the fact that i cannot allocate more than 1 Mb of memory. It does not print the contents of printf after the array and it crashes before that...
  19. Replies
    16
    Views
    4,427

    I didnt get by what you mean so what stops this...

    I didnt get by what you mean so what stops this overflowing the space. Isnt fscanf supposed to return -1 when it reaches the end of file. And i have allocated more space than is required for my...
  20. Replies
    16
    Views
    4,427

    Here is the updated code [insert] #include...

    Here is the updated code

    [insert]

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

    #define MAX_WORD_LENGTH 31
  21. Replies
    4
    Views
    1,583

    Okay but in this case since i have not appended...

    Okay but in this case since i have not appended any identifier to road so is it a static variable in this case.
  22. Replies
    4
    Views
    1,583

    static storage class

    I had a doubt about the static keyword.

    [insert]


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

    static int count;
    int road;
  23. Replies
    16
    Views
    4,427

    Still unable to make any progress. The same...

    Still unable to make any progress. The same problem is still happening. Could it be a IDE or VS issue that the file size is very large and it is not able to allocate space for this large file size.
  24. Replies
    4
    Views
    834

    A couple of issues with your program are the...

    A couple of issues with your program are the following:

    1. Never use simple main. Use int main(void) and make sure you return 0 at the end of the program.

    2. With the above program there are a...
  25. Replies
    16
    Views
    4,427

    Okay i figured out the way of doing dynamic...

    Okay i figured out the way of doing dynamic memory allocation for a 2d array using
    [insert]

    char **array2d;
    array2d = malloc(sizeof(char *) * MAX_WORDS);

    for(i = 0; i<...
Results 1 to 25 of 306
Page 1 of 13 1 2 3 4