Tags » C-2

Permission denied when trying to compile own shell in linux, what can I do?

I know this question was asked before, but I already tried to use chmod or sudo and it’s still not working. So the thing is this: 594 more words

Linux

C: Traverse a Binary Search Tree (Inorder, Postorder, Preeorder) (NON RECURSIVE)

//Traverse a Binary Search Tree (Inorder, Poetorder, Preeorder) (NON RECURSIVE)  
//   by Aniruddha

#include <stdio.h>
#include<stdlib.h>
#define STACK_SIZE 10
typedef struct node
{
	int data;
	struct node *left;
	struct node *right;
}node;
node *head=NULL;
typedef struct stack
{
        int top;
        node *items;
}stack;
 node *makeNode(int n)
{
	node *temp =(node *)malloc(sizeof(node));
	temp->data = n;
	temp->left = temp->right = NULL;
	return temp;
}
void push(stack *ms, node *item)
{
   if(ms->top < STACK_SIZE-1)   
       ms->items[++(ms->top)] = item; 
   else 
       printf("Stack is full\n");
}
node * pop (stack *ms)
{
   if(ms->top > -1 )
       return ms->items[(ms->top)--]; 
   else
       printf("Stack is empty\n");
}

int isEmpty(stack ms){
   if(ms.top < 0) return 1;
   else return 0;
}
void inorderTraversal(node *root)
{
	stack ms;
	ms.top = -1;
	node *currentnode  = root;
	while(!isEmpty(ms) || currentnode )
	{
		if(currentnode)
		{
			push(&ms, currentnode);
			currentnode = currentnode->left;
		}
		else 
		{
			currentnode = pop(&ms);
			printf("%d  ", currentnode->data);
			currentnode = currentnode->right;
		}
	}
}
void preorderTraversal(node *root)
{
	stack ms;
	ms.top = -1;
	node *currentNode = NULL;
	push(&ms,root);	// Start with root 
	while(!isEmpty(ms))
	{
		
		currentNode = pop(&ms);		
		printf("%d  ", currentNode->data);
		if(currentNode->right)
			push(&ms, currentNode->right);	// Push right child first 
		if(currentNode->left)
			push(&ms, currentNode->left);	// Push left child 
	}
}
node *peek(stack ms)
{
  if(ms.top < 0)
  {
      printf("Stack empty\n");
      return 0;
  }
   return ms.items;
}
void postorderTraversal(node *root)
{
    stack ms;
    ms.top = -1;
    node *currentNode = NULL ;
    push(&ms,root);
    node *prev = NULL;
    while(!isEmpty(ms))
    {
        currentNode = peek(ms);
        /* case 1. 237 more words
C

Is it safe to use print command in gdb?

I know that gdb allows to print expressions via print <exp> command. As I understand result of such exression is saved to gdb variables (which can be accesed with… 153 more words

Linux

[asp.net] - Query trên các computed property không hỗ trợ LINQ

Trong một project gần đây ở công ty, tôi bàng hoàng nhận ra rằng:

LINQ và Entity Framework không hỗ trợ query trên các property được tính toán dựa trên các field khác …

827 more words
ASP.NET

[asp.net mvc] Error Message - chung mà riêng

Bạn có đang dùng Entity Framework với ASP.NET MVC, cùng với đó là client-validation?

Đối với mỗi “`DataAnnotation“ attribute, bạn lại có 1 câu thông báo lỗi khác nhau, và bạn nhét tất cả chúng vào Resource? 610 more words

C#

Why standard inputs are not mixed in linux?

We know that each process has set three descriptors in advance:

0 (stdin), 1 (stdout), 2 (stderr)

Why stdin between different processes are not mixed ? 69 more words

Linux

What is the scope of signals?

What is the scope of a signal after I install it??

For example if I have in a function called A this code:

sa.sa_handler = &handle_manager_bd;
sa.sa_flags = SA_NODEFER | SA_RESTART; 
sigemptyset(&my_mask);    
sa.sa_mask = my_mask;   
sigaction(SIGUSR1, &sa, NULL);
… 158 more words
Linux