User Profile

Collapse

Profile Sidebar

Collapse
smalpani
smalpani
Last Activity: Jun 9 '10, 03:03 PM
Joined: Aug 28 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • smalpani
    replied to C - User Created Heap Testing
    in C
    I could fix some bugs. It is running the test. I am not sure if someone is up for it but at least I get motivation to test more by posting here.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <assert.h>
    
    #define NDEBUG
    /* 2MB memory all filled with 0 */
    #define KB (1024)
    #define MB (KB*KB)
    
    #define MEM_SIZE (2*MB)
    char memory[MEM_SIZE];
    ...
    See more | Go to post

    Leave a comment:


  • smalpani
    replied to C - User Created Heap Testing
    in C
    Strangely, the hyperlink does not work I don't know why, you can still copy paste the links.

    Anyway, here is the assignment:

    Memory: User created Heap
    write a program to have an array of 2mb character storage. segment the memory
    into a linked list as per following rules:

    1.each node in the list has a header and payload.

    2.header should have 2 members
    i.pointer to the...
    See more | Go to post
    Last edited by smalpani; Jul 14 '08, 05:14 PM. Reason: To get highligting C style

    Leave a comment:


  • smalpani
    started a topic C - User Created Heap Testing
    in C

    C - User Created Heap Testing

    he main routine runs a minimum test

    Here is the code
    http://phpfi.com/332069


    here is the assignment
    http://phpfi.com/332068

    I would appreciate if someone can review/approve this code
    See more | Go to post

  • first try if you do getchar(c) and putchar(c)

    rest is easy...
    See more | Go to post

    Leave a comment:


  • After calling fork do something like following in your code for the child



    Code:
    while (getppid()!=1) //One is the pid of init and if the parent dies new ppid = 1
    {
        sleep(10);   
    }
    //do the rest work here
    //THis will ensure that the child does not do any work until it is adopted by init
    See more | Go to post

    Leave a comment:


  • smalpani
    replied to algorithm
    in C
    this question always gets you till you know the trick.

    Insert the node after the node to which you have a pointer.

    Swap the contents of both the node.

    Thats it....
    See more | Go to post

    Leave a comment:


  • smalpani
    started a topic dlls and shared objects
    in C

    dlls and shared objects

    am looking for a tutorial/resource on the concept of dll s and shared objects.

    How they are created and when where and how they are loaded and by whom.



    Also it would be nice if the experts would put them in here.
    See more | Go to post

  • smalpani
    replied to pass 2d array to function
    in C
    Even this will work, i did not understand moderator's post

    [CODE=CPP]
    void printarray(int args[][],int rows,int cols)
    {
    for(int i=0;i<rows;i++)
    {
    for(int j=0;j<cols;j++)
    cout<<args[i][j]<<endl;
    }
    }
    int main()
    {
    int firstarray[][2] = {{1,2},{3,4}};
    printarray(firs tarray,2,2);
    }
    [/CODE]
    See more | Go to post

    Leave a comment:


  • smalpani
    replied to pass 2d array to function
    in C
    [CODE = c]

    void func(int array[][], int row,int col)\\
    {
    /*this is just a proof*/
    }

    int main()
    {

    int a[5][5];
    func(a,5,5);
    return 0;

    }

    [/CODE]

    This compiles without any problem for me
    See more | Go to post

    Leave a comment:


  • smalpani
    replied to about fork command in linux
    in C
    Corrected the code syntax and few other things, this should work without much clutter...
    See more | Go to post

    Leave a comment:


  • smalpani
    replied to How the header files work
    in C
    http://www.unet.univie .ac.at/aix/aixprggd/genprogc/create_shared_l ib.htm


    a little bit of google always helps...
    See more | Go to post

    Leave a comment:


  • Ha ha ha ha, you sound like

    Please make a chess program for me.

    Jokes apart, it takes more discipline than attitude to create such a program.
    I would greatly discourage using TURBO C. but you seem to have decided.


    WHATEVER THE design decisions your seniors have taken, if thats how they achieved it great, you can do the same its already proved.

    You will have to post your efforts...
    See more | Go to post

    Leave a comment:


  • smalpani
    replied to ASCII extended
    in C
    Well in DOS those characters are part of character number 127 to 255.

    For other OS I am not sure, i think unicode could be a correct idea
    See more | Go to post

    Leave a comment:


  • Just to add,

    C++ standard container define a method capacity, though not related to your question you might want to know about them. If you know already please ignore
    See more | Go to post

    Leave a comment:


  • I will xplain my understanding.

    1. In one word the answer is "yes" on unix. That is you, as a application writer should be able to retrive the size of the memory allocated from the pointer. But there is more.

    I will tell you how all this happens in linux, I have some intution on windows but not sure.

    When you make a call to malloc, it allocates a block of memory from heap to your program. And...
    See more | Go to post

    Leave a comment:


  • smalpani
    replied to about fork command in linux
    in C
    Code:
    int  main()
    {
         pid_t pids[4] = {0,0,0,0}; //be careful with these
         pid_t parentid,childid,myid;
          int i;  //why do you want to initialize these with 4
         int status;
         parentid = getpid();   //this is the original pid of the parent
          for( i =0 ;i < 4 ;i++)
          {
              myid = getpid();
              if (myid == parentid)   //only the parent forks
    ...
    See more | Go to post
    Last edited by smalpani; Oct 13 '07, 04:10 PM. Reason: corrected few errors

    Leave a comment:


  • smalpani
    replied to about fork command in linux
    in C
    Ok first lets try to identify whats wrong with your code.

    1. A call to wait requires a pointer to an integer which will contain the exit status of the child. Your call will try to write the status to a memory location 3, which is most liable to crash the program.

    2. You see to assume that a call like wait(3) will exit when the third process exits, I guess you are absolutely wrong, there is nothing like that.
    ...
    See more | Go to post

    Leave a comment:


  • the answer is that you dont ask that in a C/C++ forum if you cant do it on paper...
    See more | Go to post

    Leave a comment:


  • smalpani
    replied to transpose of a matrix
    in C
    Do that and you are out of business.

    1. you will lose elements as you are not swapping them just replacing and by the time you get to the other elements you are lost. So replace this simple statement be three statements , that first saves the target elements before swapping.

    2. Now even if you fixed that in step 1. You are lost because, you will be first swapping and then re-swapping. the two nested loops are not enf,...
    See more | Go to post

    Leave a comment:


  • smalpani
    replied to Problem with pointers
    in C
    1. Are you sure this is correct crossover logic, you ar enot using parent at all.

    2. See the trouble is you are passing the child pointers be value so whatever change in the address of child pointer value you willmake wills tay local to function. So you will have to pass a pointer to pointer to child so that the change is available with the returned function.


    So what exactly are you doing with GA. GA is cool...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...