예제 #1
0
파일: stat.c 프로젝트: aakrit/UnixProjects
static void StatCall(const struct stat *sb)
{
	printf("File type:		");
	switch (sb->st_mode & S_IFMT)
	{
		case S_IFREG: printf("reg file\n");
			break;
		case S_IFDIR: prinf("directory\n");
			break;
		case S_IFCHR: prinf("char\n");
			break;
		case S_IFBLK: prinf("block\n");
			break;
		case S_IFLNK: prinf("soft link\n");
			break;
		case S_IFIFO: prinf("FIFO/PIPE\n");
			break
		case S_IFSOCK: printf("socket\n");
			break;
		default: printf("file type not known, Please check syntax\n");
			break;
	}

	printf("I-node: major: %ld, minor: %ld\n", (long) sb->st_dev, (long) (sb->st_dev));

	printf("I-node: %ld (%s)\n", (long) sb->st_ino);


}
예제 #2
0
파일: helloworld.c 프로젝트: TomehhGG/Lab3
main()
{
    printf("Hello World!\n");
    printf("Hello You!\n");
    prinf("Making changes..\n");
    prinf("Making another change..\n");
}
예제 #3
0
int main (void)
{
    char exp[100];
    int res=-1, lock=0;
    printf("\nEnter the expression: ");
    scanf("%s",&exp);
    res=tautalogy(exp,0,strlen(exp));

    if(res==0)
        prinf("Not a tautology!");
    else
        prinf("It's a tautology!");
    return 0;
}
예제 #4
0
int main () {
	int x, y, opcao;
	printf ("\n::Menu:: \n");
	printf ("1 - Soma de dois numeros");
	printf ("2 - Diferenca entre dois numeros");
	printf ("3 - Produto entre 2 numeros");
	printf ("4 - Divisao entre 2 numeros");
	scanf ("%d", opcao);
	if (opcap == 0)
		return 0;
	prinf ("\nDigite dois valores!\n");
	scanf ("%d", x);
	scanf ("%d", y);
	switch (opcao) {
	case 1 {
		op = x + y;
	}
	case 2 {
		op = x - y;	
	}
	case 3 {
		op = x * y;
	}
	case 4 {
		op = x / y;
	}
	default {
		printf ("\nDigite um valor valido ou 0 para sair!\n")
		if (opcap == 0);
			break;
	}
	}
	return 0;
}
예제 #5
0
파일: t.c 프로젝트: Uncannytable/rbaa
void foo(int* v){
  int a = 0;
  int b = 1;
  v[a] = 10;
  v[b] = 20;
  prinf("%d", v[a]);
}
예제 #6
0
//利用邻接多重表存储结构,构造无向图G
void CreateGraph (struct Graph *G)
{
    int VertexInfo;//是否含顶点信息
    int EdgeInfo;//是否含边信息
    int i, j, k;
    char s[MAX_INFO];
    struct VertexType a, b;
    struct EdgeTyle *p;

    prinf("请输入无向图G的顶点个数,顶点是否含其他信息(是:1,否:0):");
    scanf("%d%d",G->vexnum, &VertexInfo);
    printf("请输入%d个顶点的值\n",G->vexnum);
    for (i = 0; i < G->vexnum; i++)
    {
        scanf("%s", &G->adjmulist[i].data.name);
        G->adjmulist[i].firstedge = NULL;
        //顶点其他信息
        if (VertexInfo)
        {
            printf("输入该顶点其他信息:\n");
            scanf("%s",s);
            int length = strlen(s);
            if (length)
            {
                G->adjmulist[i].data.info = (char *) malloc ((length + 1) * sizeof (char));
                strcpy(G->adjmulist[i].data.info, s);
            }//end if
        }//end if
    }//end for
    printf("请输入边的条数,边是否含其他信息(是:1,否0):");
    scanf("%d%d",G->edgenum, &EdgeInfo);
    printf("输入每条边的两个端点以及该边的长度,空格分割\n");
    for (k = 0; k < G->edgenum; k++)
    {
        scanf("%s%s",a.name, b.name);
        i = LocateVex(&G, a);
        j = LocateVex(&G, b);
        p = (struct EdgeTyle *) malloc (sizeof(struct EdgeTyle));
        p->ivex = i;
        p->jvex = j;
        p->info = NULL;
        p->ilink = G->adjmulist[i].firstedge;//插在表头
        G->adjmulist[i].firstedge = p;
        p->jlink = G->adjmulist[j].firstedge;//插在表头
        G->adjmulist[j].firstedge = p;
        scanf("%d",&p->length);
        if (EdgeInfo)
        {
            printf("输该边其他信息:\n");
            scanf("%s",s);
            int length = strlen(s);
            if (length)
            {
                p->info = (char *) malloc ((length + 1) * sizeof (char));
                strcpy(p->info, s);
            }
        }//end if
    }//end for
}
예제 #7
0
파일: bs.c 프로젝트: akkpatel/cs252
int main(){
	const char *s1 = "aashay and anand";
	const char *s2 = "anand";

	const char *hello = malloc(strlen(s1));
	hello = strstr(s1,"and");
	prinf("hi %s", hello);
}
예제 #8
0
/*
*Funcion
*Principal
*/
int main(){
	float numf = 1.2;
	int numI = 0, i = 0;
	printf( "Ingrese un numero: " );
	scanf( "%s" ,&numI );
	if( numI > = 10){
		prinf( "Hola mundo!");
	}else{
예제 #9
0
void main(){
	int i = 0;
	printf("Hello World!! :D");
	prinff("I am the real master");
	for(i = 0; i<10 ; i++){
		printf("%d",i);
		if(i<5) printf("low");
		else prinf("high");
	}
	printf("ififelse");
}
예제 #10
0
/*----------------------------------------------------------------
* [function name]
*
* [Description]
*
* Arguments:
*	[arglist]
*
* Returns: 
*	[retlist]
*
* Side effects:
*	[desc]
*
* Call context:
*	[desc]
----------------------------------------------------------------*/
int afunction(void)
{
        DBFENTER;

        if ( a ) {
                prinf("xxx");
        }


        DBFEXIT;
        return 0;
}
예제 #11
0
파일: pointers.c 프로젝트: tempdist/C-codes
/* sort input lines */
main()
{
	int nlines;		/* number of input lines read */
	if ((nlines = readlines(lineptr, MAXLINES)) >= 0) {
		qsort(lineptr, 0, nlines-1);
		writelines(lineptr, nlines);
		return 0;
	}
	else {
		prinf("error: input too long to sort\n");
		return 1;
	}
}
예제 #12
0
파일: graph.c 프로젝트: matrix01/Uva-Solve
int main(){
	int m[25][25];
	int v, e;
	char ch=97;
	char ch1=98;
	int i, j, k;
	scanf("%d%d", v, e);
	for(i=0; i<v; i++){
		for(j=0; j<e; j++){
			scanf("%d", m[i][j]);
			if(m[i][j]==0){
				prinf("%c is not conected to %c", ch++, ch1++);	
			}
		}
	}
	return 0;
}
예제 #13
0
파일: panalysis.c 프로젝트: hittlle/nids
void analysis_llc(const u_char *bp, int length)
{
    llc_header_t *llc;
    u_int8_t org_id[3];
    u_int16_t ethertype;
    u_int8_t control;
    llc = (llc_header_t *)bp;

    printf("LLC header \n");
    printf("DSAP: %d",llc->dsap);
    printf("SSAP:%d",llc->ssap);
    if(llc->dsap == 255 && llc->ssap == 255) {
        printf("analysis_ipx \n");
        return;
    }

    control = *(bp +2);
    prinf("Control: %d",control);
    gdk_threads_enter();
    add_list_to_clist6();

    gdk_threads_leave();
    if(llc->dsap == 240 && llc->ssap == 240) return;

    if(llc->dsap == 224 && llc->ssap == 224) {
        analysis_ipx(pkt );
        return;
    }
    if(llc->dsap == 170 && llc->ssap == 170) {
        org_id[0] =*(bp +3);

        org_id[1] =*(bp +4);
        org_id[1] =*(bp +5);

        ethertype = *(bp + 6);
        ethertype = ntohs(ethertype);
        printf("SNAP header");
        printf("Organization ID %d",org_id);
        printf("Protocol: %d",ethertype );

    }
    return;


}
예제 #14
0
파일: reminder.c 프로젝트: dgets/reminder
int main(int argc, char *argv) {
	void	*options, *events;
	bool	fullscr = false;
	int	tmp;

	/* parse command line here */
	options = pcline(argc, argv);
	if (options == NULL) {	/* oopthspthspthsie! */
		prinf("\nUnable to allocate memory!\n");
		return 1;
	}

	if (((bool) *options) == true) {	/* we're editing */
		fullscr = init_ncurses();
		/* TODO: Implement non-fullscreen functionality */

		while ((tmp = event_editor(events, fullscr)) != 5) {
		  switch (event_editor(events, fullscr)) {
		    case 1: /* list events */
			list_events(*events);
			break;
		    case 2: /* delete event(s) */
			delete_events(*events);
			break;
		    case 3: /* add event(s) */
			add_events(*events);
			break;
		    case 4: /* edit event */
			ed_event(*events);
			break;
		    case 5: /* exit */
			return 0;
			break;
		    default:
			err("\n\nWTF?\nFell through main loop: %s\n");
		  }
		}
	
	} else if (((bool) *(options + 1)) == true) { /* fork & notify */
		if (notifyd != 0) return 2;
	}

}
예제 #15
0
파일: leap.c 프로젝트: Aghalya/Mycodeworld
int main()
{
  int year;
  scanf("%d",&year);
  if(year%4==0)
  {
    if(year%100==0)
    {
      if(year%400==0)
        printf("Leap year");
      else
        printf("Not Leap year");
    }
    else
      printf("Leap year");
  }
  else
    prinf("Not Leap year");
  return 0;  
}
예제 #16
0
파일: rand.c 프로젝트: ondasempre/c
main()
{

 int i;
 unsigned sid;
 printf ("Enter sid: ");
 scanf ("%u", &sid);
 srand (sid);
 
 for (i = 1; i <= 10; i++) {
 prinf ("%10d", 1 + (rand() % 6));
 
 if (i % 5 == 0)
 printf ("\n");
 
}

return 0;

}
예제 #17
0
int main()
{
 int n, first = 0, second = 1, next, c;
int switch;
 printf("Enter the number of terms\n");
 scanf("%d",&n);

 for ( c = 0 ; c < num ; c++ )
 {
 if ( c <= 1 )
 next = c;
 else
 {
 next = first + second;
 first == second;
 second = next;
 }
 printf("%d\n",next);
 else
 prinf(“Unsuccessful\n”);
 }
예제 #18
0
파일: q5.c 프로젝트: ugurdonmez/tutorials
int main() {
   
   int ageA,ageB;
   
   printf("Enter the age of first person: ");
   scanf("%d",&ageA);
   
   printf("Enter the age of second person: ");
   scanf("%d",&ageB);
   
   if ( ageA > ageB ) {
      printf("A is older than B\n");
   }
   else if ( ageA < ageB ) {
      prinf("A is younger than B\n");
   }
   else {
      printf("Equal age\n");
   }
   
   return 0;
}
int main (void) {
  prinf("Hello World\n");
}
예제 #20
0
main(){
	prinf("masarap mag-aral kaso mas masarap matulog");
}
예제 #21
0
int main(){

    prinf("bonjour!!\n"); //mise a jour a partir du dashboard
    return 0;
}
예제 #22
0
파일: t.c 프로젝트: Uncannytable/rbaa
void bar(int* v, int a, int b){
  v[a] = 10;
  v[b] = 20;
  prinf("%d", v[a]); 
}
예제 #23
0
void displaystat(struct stat *st)
{
     /* display  file name: if it is a symbolic link ,also show link file name */

     /*display file size,block,io block and file type->*/
        printf("  Size:  %d       Blocks: %d          IO Block: %d   ", 
            st->st_size, st->st_blocks, st->st_blksize);
          
        if (S_ISDIR(st->st_mode))
            printf("    directory\n");
        else if(S_ISREG(st->st_mode))
            printf("    regular file\n");
        else if(S_ISLNK(st->st_mode))
            printf("    symbolic (soft) link\n");
        else if(S_IFCHR(st->st_mode))
            printf("    character device\n");
        else if(S_IFBLK(st->st_mode))
            prinf("     block device\n");
        else if(S_IFIFO(st->st_mode))
            printf("    FIFO or pipe\n");
        else if(S_IFSOCK(st->st_mode))
            printf("    socket\n");
        else printf("   file type unknown?\n");

        printf("Device:  %xh/%dd    Inode:  %ld     Links:    %ld\n",
            st->st_dev, st->st_dev, (long) st->st_ino, (long) st->st_nlink);
        // creating pointers to struct passwd and group type to get owner name and group by userid
        struct passwd *passent; 
        passent=getpwuid(st->st_uid);

        struct group *group;
        group=getgrgid(st->st_gid);
       
       /*get permission mask and rwx format*/
        char *ac=calloc(10,1); //calloc intializes buffer space 10 elements each 1 unit long and return pointer to this location
        memset(ac,'-',10);

        if(st->st_mode & S_IFDIR) ac[0]='d';
        if(S_ISLNK(st->st_mode))  ac[0]='l';
        if(st->st_mode & S_IRUSR) ac[1]='r';
        if(st->st_mode & S_IWUSR) ac[2]='w';
        if(st->st_mode & S_IXUSR) ac[3]='x';
        if(st->st_mode & S_IRGRP) ac[4]='r';
        if(st->st_mode & S_IWGRP) ac[5]='w';
        if(st->st_mode & S_IXGRP) ac[6]='x';
        if(st->st_mode & S_IROTH) ac[7]='r';
        if(st->st_mode & S_IWOTH) ac[8]='w';
        if(st->st_mode & S_IXOTH) ac[9]='x';


        printf("Access:  (%o%o%o%o/%s)     Uid:  (%d/   %s)   Gid: (%d/  %s)\n", 
        (st->st_mode & S_ISVTX)>>9, (st->st_mode & S_IRWXU)>>6, (st->st_mode & S_IRWXG)>>3,
        st->st_mode & S_IRWXO, ac, st->st_uid, passent->pw_name, st->st_gid, group->gr_name);
        
        /*use strftime to get the access,modify and change time*/
        char date_time[40];
        strftime(date_time,sizeof(date_time),"Access:  %Y-%m-%d %H:%M:%S %z",localtime(&st->st_atim->tv_sec));
        puts(date_time);
        strftime(date_time,sizeof(date_time),"Modify:  %Y-%m-%d %H:%M:%S %z",localtime(&st->st_mtim->tv_sec));
        puts(date_time);
        strftime(date_time,sizeof(date_time),"Change:  %Y-%m-%d %H:%M:%S %z",localtime(&st->st_ctim->tv_nsec));
        puts(date_time);
}