C programming

About

In computing, C (/ˈsiː/, as in the letter C) is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs.[5][6] Like most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. Its design provides constructs that map efficiently to typical machine instructions, and therefore it has found lasting use in applications that had formerly been coded in assembly language, most notably system software like the Unix computer operating system.[7] C is one of the most widely used programming languages of all time,[8][9] and C compilers are available for the majority of available computer architectures and operating systems. Many later languages have borrowed directly or indirectly from C, including D, Go, Rust, Java, JavaScript, Limbo, LPC, C#, Objective-C, Perl, PHP, Python, Verilog (hardware description language),[4] and Unix's C shell. These languages have drawn many of their control structures and other basic features from C. Most of them (with Python being the most dramatic exception) are also very syntactically similar to C in general, and they tend to combine the recognizable expression and statement syntax of C with underlying type systems, data models, and semantics that can be radically different. C++ and Objective-C started as compilers that generated C code; C++ is currently nearly a superset of C,[10] while Objective-C is a strict superset of C.[11][12][13] Before there was an official standard for C, many users and implementors relied on an informal specification contained in a book by Dennis Ritchie and Brian Kernighan; that version is generally referred to as "K&R" C. In 1989 the American National Standards Institute published a standard for C (generally called "ANSI C" or "C89"). The next year, the same specification was approved by the International Organization for Standardization as an international standard (generally called "C90"). ISO later released an extension to the internationalization support of the standard in 1995, and a revised standard (known as "C99") in 1999. The current version of the standard (now known as "C11") was approved in December 2011


C programming
October 9, 2014 · Public

LINKED LIST IN C - BASICS :D

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

/*FUNCTION PROTOTYPES*/

/*I define the information field structure..
It can be a simple integer value but we can define it as a structured type*/
struct SInfo{
int value;
};

/*I define a new data type called 'TInfo' of SInfo type*/
typedef struct SInfo TInfo;

/*I create list node structure*/
struct SNode{
/*Information field in the list node*/
TInfo info;
/*pointer to the next node*/
struct SNode *next;
};

/*I define a new var type called 'TNode' of SNode type*/
typedef struct SNode TNode;

/*I define a pointer to TNode called TList*/
typedef TNode *TList;

/*Return list pointer, create a new list*/
TList create_list();


TInfo read_info();
TList insert_element(TList,TInfo);
TList delete_list(TList);
void print_list(TList);

int main(){
int i,n;
TList first;
TInfo info;

printf("\t\t\tLIST EXERCISE!\n");

printf("Insert elements number :");
scanf("%d",&n);

first=create_list();

for(i=0;i<n;i++){

info = read_info();

first = insert_element(first,info);

}

print_list(first);

first = delete_list(first);

fflush(stdin);
getchar();
}

/*FUNCTION DECLARATION*/

TList create_list(){
return NULL;
}

TInfo read_info(){
TInfo info;
printf("Insert number :");
scanf("%d",&info.value);
return info;
}
/*Sorted elements inserting*/
/*
F!: Position search
F2: Dinamic allocation
F3: Pointers updating*/

TList insert_element(TList first,TInfo info){
TList prec,current,newnode;

prec=NULL;
current=first;

/*F1: Posittion search */
while(current!=NULL && info.value > current->info.value ){
prec=current;
current=current->next;
}

/*F2: Dinamic allocation*/
newnode=(TNode *)malloc(sizeof(TNode));
/*Control allocation outcame*/
assert(newnode!=NULL);

newnode->info=info;

/*F3:Pointers updating */
if(prec==NULL){
newnode->next=first;
first=newnode;
return first;
}else{
prec->next=newnode;
newnode->next=current;
return first;
}


}

void print_list(TList first){
TList current;

current=first;
printf("\n");

while(current!=NULL){
printf("\t%d",current->info.value);
/* pointer incrementation */
current=current->next;
}

}

TList delete_list(TList first){
TList current,success;

current=first;

while(current!=NULL){

success=current->next;

free(current);

current=success;

}

return NULL;

}



C programming
October 8, 2014 · Public

Take view at B* tree code in C !

http://www.amittai.com/prose/bpt.c


C programming
October 5, 2014 · Public

Welcome to C programming language page !

C programming
October 5, 2014 · Public