EmbLogic's Blog

scull for adding one item……………….. try on gcc it may require some modification

#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/stat.h>
//#include<fcntl.h>
//#include<unistd.h>
#include<string.h>

#define QSET 3           //size of the pointer array ,points to quantum.
#define QUANTUM 4        //size of quantum.

struct scull_dev
{
	struct scull_qset *data;            //points to scull qset
	int qset;                          //qset size
	int quantum;                       // quantum size
};

struct scull_qset                  // link list structure
{
	struct scull_qset *next;
	char **data;
};

int data(struct scull_dev*);       //entering data.
void display(struct scull_dev*);    // to display data.

int main()
{
	struct scull_dev *link;       //link list pointer

	link=(struct scull_dev *)malloc(sizeof(struct scull_dev));

	//....................scull data.......
	data(link);
	//.........distplay.....................
	display(link);
	return 0;
}

//.......entering into the 2D array .............
int data(struct scull_dev *start)

{       int i;

	start->data=(struct scull_qset*)malloc(sizeof(struct scull_qset));
	start->data->next=NULL;
	start->data->data=malloc(sizeof(char)*QSET);
	for(i=0;i<QSET;i++)
	{
	    start->data->data[i]=malloc(sizeof(char)*QUANTUM);
	    start->data->data[i]="abcd";

	}      //quantum end
	return 0;
}
//........display function.................
void display(struct scull_dev *start)
{
	int i;
		for(i=0;i<QSET;i++)
	{

	   printf("\n%s", start->data->data[i]);

	}      //quantum end

}

One Response to scull for adding one item……………….. try on gcc it may require some modification

  1. how to use ……….void **data ?????

Leave a Reply to Kuldeep Dhanotia Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>