User Profile

Collapse

Profile Sidebar

Collapse
Ankit Khare
Ankit Khare
Last Activity: Apr 29 '11, 05:35 AM
Joined: Mar 4 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Ankit Khare
    started a topic Pushing shared objects into MeeGo

    Pushing shared objects into MeeGo

    I need to push the .so(shared objects) of my application(wri tten in C) into the new MeeGo operating system.I have never done this porting before and have no clue where do i push them,which cross compilers reqd etc.
    SDK i have found for MeeGo 1.1, but i guess that is for designing the application from the scratch?I am not sure..if somebody can give me any idea,that'll be really helpful.
    Note:MeeGo is written in C++ it seems
    ...
    See more | Go to post

  • Ohk,let me put it this way,we say that the "heap grows". What exactly is meant by that?
    **If, on doing malloc(), memory is taken from the heap then why do we say that the heap grows?
    See more | Go to post

    Leave a comment:


  • Memory is added to the heap or taken from the heap?

    We say that in a C process' memory layout,the heap segment deals with the dynamic memory allocation i.e. malloc,calloc.

    When we do
    Code:
    int *p=malloc(100000);
    100000 bytes are :
    1.taken from the system memory and whole 100000 bytes added into the process' heap memory segment

    2.taken from the process' heap memory(process' heap already had this memory,it has turned accessible now )

    3.taken from...
    See more | Go to post

  • Ankit Khare
    replied to Double pointers!
    in C
    I am attaching the whole code,please somebody run it yourself and tell me about this issue.
    In function delete,*ptr=(*ptr)->nextis deleting the node successfully,co nfusing part is not the traversing or what i am doing,but what is happening at the address of the node to be deleted



    Code:
    #include<stdio.h>
    #include<stdlib.h>
    
    typedef struct node{
    int value;
    struct node *next;
    ...
    See more | Go to post

    Leave a comment:


  • Ankit Khare
    replied to Double pointers!
    in C
    I am retunrning temp back to main(),where i am holding this returned value in another node **ptr.,and then i am doing *ptr=(*ptr)->next;
    Ok,i'll change the code a little bit,i am not returning temp any more.Now my delete function's protoype will be :
    Code:
    [B]void[/B] delete(int value)
    {
    ..
    ..same as before..
     if(flag==1)
             {
               [B] *temp=(*temp)->next;[/B]
             }
    }
    this will also delete...
    See more | Go to post

    Leave a comment:


  • Ankit Khare
    replied to Double pointers!
    in C
    I agree, what's happening in that line is similar to:
    Code:
    node *current
    current=current->next
    means exactly whats happening at *ptr=(*ptr)->next;
    But using single pointer to the node,if you would have done
    current=current->next,it wont effect the link list at all,it will remain as it is,but using double pointer this line
    *ptr=(*ptr)->next is actually deleting the node.

    How it is traversing...
    See more | Go to post

    Leave a comment:


  • Ankit Khare
    started a topic Double pointers!
    in C

    Double pointers!

    I have written a code of deleting a node from a link list using double pointers,i am not sure if i'll be able to explain what i want to ask..
    so the code goes like this:
    Code:
    node **ptr=NULL;
    node **delete(int value)
    {
    	int flag=0;
    	node **temp=&root;
    	while(*temp!=NULL)
    	{
    		if((*temp)->value==value)
    		{
    			flag =1;
    			break;
    		}
    		else
    			{
    ...
    See more | Go to post

  • Ankit Khare
    started a topic name of the array decays to pointer..
    in C

    name of the array decays to pointer..

    Code:
    char *p="Hello";
    char q[]="Hello";
    p++;
    q++;// THIS LINE GIVES ERROR,LValue reqd as increment operand  
    printf("%s %s\n",p,q);
    The name of the array decays to pointer except 2 at 2 cases(sizeof and & operator).
    So when q in the above example decays to pointer,why it is giving error in q++ whereas p++ is doing fine.?
    See more | Go to post

  • Ankit Khare
    started a topic Function Pointers
    in C

    Function Pointers

    Is'nt it necessary that a function pointer's protoype must be absolutely same as the function for which it is intended?
    eg:
    Code:
    typedef void (*func)();
    
    void someFunc(int i,int j)
    {printf("%d %d",i,j);}
    
    void main()
    {
    func temp=someFunc;
    temp(2,3);
    }
    This works fine!It does'nt matter whether or not i am passing any arguments?how the arguments are resolved...
    See more | Go to post

  • #define is a macro,a preprocessor directive,its simply a textual replacement,so wherever you have written PI in your code will be replaced to 3.1416 before the compiler comes into the picture.
    Whereas in the other case you are a declaring a const float variable,by const it means your code cannot change its value anywhere in the code.

    One other difference is where ever you have used #defined value,that will be treated as double,whereas...
    See more | Go to post

    Leave a comment:


  • Ankit Khare
    replied to How to print address of enum?
    in C
    So where are these names to these enum constants are stored?Suppose if i have defined enum but i have'nt created a variable of it,then when i am trying to access any member of it,i still get the right value.Where are these names fetched from?
    See more | Go to post

    Leave a comment:


  • Ankit Khare
    started a topic How to print address of enum?
    in C

    How to print address of enum?

    As i read size of enum is sufficient enough to hold any integer value,thus its 4 bytes in my machine.
    Code:
    typedef enum{
    Monday,
    Tuesday,
    Wednesday,
    Thursday,
    Friday,
    Saturday,
    Sunday
    }weekday;
    
    
    void main()
    {
            weekday day=Tuesday;
            printf("%d\n",day);// prints 1,correct
            printf("%d\n",Wednesday);//Prints 2!How
    ...
    See more | Go to post

  • I am using linux and gcc. If somebody can also post some link where i can find details about memory mapping of a process,that will be of great help.
    See more | Go to post

    Leave a comment:


  • Does each running program / process have its own stack, and a heap too?

    "The heap grows and the stack decreases, both approach towards each other, if they crosses each other, program crashes"

    I have read this at a number of places but am confused in it. Each running program/process has its own stack, and a heap too? Heap is separate for each program or common for n number of processes?
    See more | Go to post
    Last edited by Niheel; Mar 11 '11, 05:45 AM.

  • Ankit Khare
    started a topic Malloc and calloc,real difference?
    in C

    Malloc and calloc,real difference?

    Code:
    calloc(sizeof m,n);
    //is equivalent to
    int *p=malloc(m*n);
    memset(p,0,sizeof m*n);
    Thats it?Is there any other major difference between the two other than no of arguments and initialization to 0?
    See more | Go to post

  • Ok,so compiler expects me to write main() as either of the following:
    Code:
    1.void main(){}
    //I can use neither argc,argv nor env 
    
    2.void main(int argc){}
    //I can only use argument count,but not argv or env
    
    3.void main(int argc,char **argv)
    //I can use argument count, argv but not env
    
    4.void main(int argc,char **argv, char **env)
    I can access all.
    No...
    See more | Go to post

    Leave a comment:


  • Ohk,didnt knew about that.But as you are saying ATLEAST 2 arguments is what i am not getting.
    as i have observed that
    Code:
    void main(int argc)
    works fine!.Then why not
    Code:
    void main(char **argv)
    works?
    See more | Go to post

    Leave a comment:


  • i am sorry i didnt get you,you said atleast 2 arguments,what other arguments can be passed to main?how?
    See more | Go to post

    Leave a comment:


  • Ankit Khare
    started a topic Why main() works also only with argc but not argv?
    in C

    Why main() works also only with argc but not argv?

    I am confused in command line arguments to a C program a little bit.
    The argc maintains the count of the arguments passed and argv is array of vector to these arguments.But when i do :
    Code:
    void main(int argc)
    {
    printf("%d\n",argc);
    }
    It does the required job.But if i do:
    Code:
    void main(char **argv)
    {
    printf("%s\n",argv[0]);
    }
    i get a warning and...
    See more | Go to post
No activity results to display
Show More
Working...