Tuesday, May 31, 2011

File Handling In C

Hello Friends,

File Handing in C language is one of the most important topic. The program which written below will make one file and you can write your data as you wanted.

Example:

#include<conio.h>
#include<stdio.h>

void main()
{
      FILE *f1;                    // File pointer variable declared
      char c;

      printf("Enter Data\n\n");

      f1=fopen("DATA","w");  // File DATA created and ready to write

     while((c=getchar()) != EOF)
     {
             
                 putc(c,f1);

     }
     fclose(f1);
     printf("\n\nYour Data in File:\n\n");

    f1=fopen("DATA","r")                // File will open in read mode

    while((c=getc(f1)) !=EOF)
   {
            printf("%c",c);
   }

 fclose(f1);

getch();

}

Monday, May 23, 2011

Top 10 Universities for Computer Science

The University of Texas at Austin Department of Computer Science is recognized as one of the top 10 computer science programs nationally and internationally. The department enjoys close ties with other groups on the UT Austin campus engaged in computing research, namely the Department of Electrical and Computer Engineering, the Institute for Computational Engineering and Sciences, and the Texas Advanced Computing Center.

Computing Science at the University of Glasgow was ranked as the top department in Scotland and as one of the top five departments in the UK in the Times Good University Guide 2010. It was also rated as one of the top 10 computing science departments in the UK in the Research Assessment Exercise 2008.

The Department of Computer Science (DCS) at the University of Toronto is among the top-ranked computer science departments in North America, and it is the only Canadian university ranked in the global top 10 for the subject in ARWU 2009. It offers a wide array of research opportunities and programs of study.

Ranking of World's Top 10 Universities for Computer Science:


1 Stanford University
2 MIT
3 University of California, Berkeley
4 Carnegie Mellon University
5 Princeton University
6 Cornell University
7 The University of Texas at Austin
8 University of Toronto
9 California Institute of Technology
9 University of Southern California

Saturday, May 21, 2011

T Y BCA

College Reopen - 16th June 2011, 10 a.m.

Result (4th SEM) - In First week of June




Visit my second website: www.thewebdream.com

Saturday, May 14, 2011

AJAX


Introduction - What is AJAX?

AJAX, or Asynchronous JavaScript and XML, is a fancy way to use JavaScript and XML to communicate with a web server without refreshing the web page. You can visit this web page for more information about AJAX; it has a good list of links.

Why use AJAX?

There are a couple of reasons to use AJAX in lieu of the traditional form submission. The first is that it is very light weight: instead of sending all of the form information to the server and getting all of the rendered HTML back, simply send the data the server needs to process and get back only what the client needs to process. Light weight means fast. The second reason to use AJAX is because (as the logo in the link above makes clear) AJAX is cool.


Asynchronous JavaScript + XML (AJAX) is essentially a branding term for a bundle of common web technologies. These include JavaScript, DHTML and a utility object called XMLHTTP. The short story is that in combination, these tools reduce the need for web browser applications to reconnect to a web server every time additional data is downloaded.

Not to be left behind, Microsoft has announced project Atlas for ASP.NET 2.0 and for ASP.NET 1.1, we already have Michael Schwarz's Ajax.Net.
According to one Atlas project member, “What we’ve set out to do is to make it dramatically easier for anyone to build AJAX-style web applications that deliver rich, interactive, and personalized experiences. Developers should be able to build these applications without great expertise in client scripting; they should be able to integrate their browser UI seamlessly with the rest of their applications; and they should be able to develop and debug these applications with ease.”
Atlas is being developed on top of ASP.NET 2.0 and is slated to contain the following components:

Atlas Client Script Framework
The Atlas Client Script Framework is an extensible, object-oriented 100% JavaScript client framework that allows you to easily build AJAX-style browser applications with rich UI and connectivity to web services. With Atlas, you will be able to write web applications that use a lot of DHTML, JavaScript, and XMLHTTP, without having to be an expert in any of these technologies.
The Atlas Client Script Framework will work on all modern browsers, and with any web server. It also won’t require any client software installations, only standard script references in the web page.
The Atlas Client Script Framework will include the following components:
  • An extensible core framework that adds features to JavaScript such as lifetime management, inheritance, multicast event handlers, and interfaces
  • A base class library for common features such as rich string manipulation, timers, and running tasks
  • A UI framework for attaching dynamic behaviors to HTML in a cross-browser way
  • A network stack to simplify server connectivity and access to web services
  • A set of controls for rich UI, such as auto-complete textboxes, popup panels, animation, and drag and drop
  • A browser compatibility layer to address scripting behavior differences between browsers.
ASP.NET Server Controls for Atlas
For ASP.NET applications, a new set of AJAX-style ASP.NET Server Controls will be developed and the existing ASP.NET page framework and controls will be enhanced to support the Atlas Client Script Framework.
The Atlas Client Script Framework will fully support ASP.NET 2.0 client callbacks, but will enrich the level of integration between the browser and the server. For example, you will be able to data bind Atlas client controls to ASP.NET data source controls on the server, and you’ll be able to control personalization features of web parts pages asynchronously from the client.

ASP.NET Web Services Integration
Like any client application, an AJAX-style web application will usually need to access functionality on the web server. The model for connecting to the server for Atlas applications is the same as for the rest of the platform – through the use of Web services.

With ASP.NET Web Services Integration, Atlas applications will be able to access any ASP.NET-hosted ASMX or Indigo service directly through the Atlas Client Script Framework, on any browser that supports XMLHTTP. The framework will automatically handle proxy generation, and object serialization to and from script. With web services integration, you can use a single programming model to write your services, and use them in any application, from browser-based sites to full smart client applications.


Thursday, May 12, 2011

HTML Color Values


Color Values

HTML colors are defined using a hexadecimal notation (HEX) for the combination of Red, Green, and Blue color values (RGB).

The lowest value that can be given to one of the light sources is 0 (in HEX: 00). The highest value is 255 (in HEX: FF).

HEX values are specified as 3 pairs of two-digit numbers, starting with a # sign.

Examples:


Color Values

ColorColor HEXColor RGB
#000000rgb(0,0,0)
#FF0000rgb(255,0,0)
#00FF00rgb(0,255,0)
#0000FFrgb(0,0,255)
#FFFF00rgb(255,255,0)
#00FFFFrgb(0,255,255)
#FF00FFrgb(255,0,255)
#C0C0C0rgb(192,192,192)
#FFFFFFrgb(255,255,255)

Monday, May 9, 2011

C Programming - File management in C


C supports a number of functions that have the ability to perform basic file operations, which include:
1. Naming a file
2. Opening a file
3. Reading from a file
4. Writing data into a file
5. Closing a file

  • Real life situations involve large volume of data and in such cases, the console oriented I/O operations pose two major problems
  • It becomes cumbersome and time consuming to handle large volumes of data through terminals.
  • The entire data is lost when either the program is terminated or computer is turned off therefore it is necessary to have more flexible approach where data can be stored on the disks and read whenever necessary, without destroying the data. This method employs the concept of files to store data.

File operation functions in C:

Function Name
Operation
fopen()
Creates a new file for useOpens a new existing file for use
fclose
Closes a file which has been opened for use
getc()
Reads a character from a file
putc()
Writes a character to a file
fprintf()
Writes a set of data values to a file
fscanf()
Reads a set of data values from a file
getw()
Reads a integer from a file
putw()
Writes an integer to the file
fseek()
Sets the position to a desired point in the file
ftell()
Gives the current position in the file
rewind()
Sets the position to the begining of the file

Defining and opening a file:

If we want to store data in a file into the secondary memory, we must specify certain things about the file to the operating system. They include the fielname, data structure, purpose.

The general format of the function used for opening a file is

FILE *fp;
fp=fopen(“filename”,”mode”); 

The first statement declares the variable fp as a pointer to the data type FILE. As stated earlier, File is a structure that is defined in the I/O Library. The second statement opens the file named filename and assigns an identifier to the FILE type pointer fp. This pointer, which contains all the information about the file, is subsequently used as a communication link between the system and the program.
The second statement also specifies the purpose of opening the file. The mode does this job.

R open the file for read only.
W open the file for writing only.
A open the file for appending data to it.

Consider the following statements:

FILE *p1, *p2;
p1=fopen(“data”,”r”);
p2=fopen(“results”,”w”);

In these statements the p1 and p2 are created and assigned to open the files data and results respectively the file data is opened for reading and result is opened for writing. In case the results file already exists, its contents are deleted and the files are opened as a new file. If data file does not exist error will occur.

Closing a file:

The input output library supports the function to close a file; it is in the following format.
fclose(file_pointer);

A file must be closed as soon as all operations on it have been completed. This would close the file associated with the file pointer.
Observe the following program.

….
FILE *p1 *p2;
p1=fopen (“Input”,”w”);
p2=fopen (“Output”,”r”);
….

fclose(p1);
fclose(p2)

The above program opens two files and closes them after all operations on them are completed, once a file is closed its file pointer can be reversed on other file.

The getc and putc functions are analogous to getchar and putchar functions and handle one character at a time. The putc function writes the character contained in character variable c to the file associated with the pointer fp1. ex putc(c,fp1); similarly getc function is used to read a character from a file that has been open in read mode. c=getc(fp2).

The program shown below displays use of a file operations. The data enter through the keyboard and the program writes it. Character by character, to the file input. The end of the data is indicated by entering an EOF character, which is control-z. the file input is closed at this signal.

#include< stdio.h >
main()
{
file *f1;
printf(“Data input output”);
f1=fopen(“Input”,”w”); /*Open the file Input*/
while((c=getchar())!=EOF) /*get a character from key board*/
putc(c,f1); /*write a character to input*/
fclose(f1); /*close the file input*/
printf(“nData outputn”);
f1=fopen(“INPUT”,”r”); /*Reopen the file input*/
while((c=getc(f1))!=EOF)
printf(“%c”,c);
fclose(f1);
}

The getw and putw functions:

These are integer-oriented functions. They are similar to get c and putc functions and are used to read and write integer values. These functions would be usefull when we deal with only integer data. The general forms of getw and putw are:

putw(integer,fp);
getw(fp);

/*Example program for using getw and putw functions*/
#include< stdio.h >
main()
{
FILE *f1,*f2,*f3;
int number I;
printf(“Contents of the data filenn”);
f1=fopen(“DATA”,”W”);
for(I=1;I< 30;I++)
{
scanf(“%d”,&number);
if(number==-1)
break;
putw(number,f1);
}
fclose(f1);
f1=fopen(“DATA”,”r”);
f2=fopen(“ODD”,”w”);
f3=fopen(“EVEN”,”w”);
while((number=getw(f1))!=EOF)/* Read from data file*/
{
if(number%2==0)
putw(number,f3);/*Write to even file*/
else
putw(number,f2);/*write to odd file*/
}
fclose(f1);
fclose(f2);
fclose(f3);
f2=fopen(“ODD”,”r”);
f3=fopen(“EVEN”,”r”);
printf(“nnContents of the odd filenn”);
while(number=getw(f2))!=EOF)
printf(“%d%d”,number);
printf(“nnContents of the even file”);
while(number=getw(f3))!=EOF)
printf(“%d”,number);
fclose(f2);
fclose(f3);
}

The fprintf & fscanf functions:

The fprintf and fscanf functions are identical to printf and scanf functions except that they work on files. The first argument of theses functions is a file pointer which specifies the file to be used. The general form of fprintf is

fprintf(fp,”control string”, list);

Where fp id a file pointer associated with a file that has been opened for writing. The control string is file output specifications list may include variable, constant and string.

fprintf(f1,%s%d%f”,name,age,7.5);

Here name is an array variable of type char and age is an int variable
The general format of fscanf is

fscanf(fp,”controlstring”,list);

This statement would cause the reading of items in the control string.

Example: 
fscanf(f2,”5s%d”,item,&quantity”);

Like scanf, fscanf also returns the number of items that are successfully read.

/*Program to handle mixed data types*/
#include< stdio.h >
main()
{
FILE *fp;
int num,qty,I;
float price,value;
char item[10],filename[10];
printf(“Input filename”);
scanf(“%s”,filename);
fp=fopen(filename,”w”);
printf(“Input inventory datann”0;
printf(“Item namem number price quantityn”);
for I=1;I< =3;I++)
{
fscanf(stdin,”%s%d%f%d”,item,&number,&price,&quality);
fprintf(fp,”%s%d%f%d”,itemnumber,price,quality);
}
fclose (fp);
fprintf(stdout,”nn”);
fp=fopen(filename,”r”);
printf(“Item name number price quantity value”);
for(I=1;I< =3;I++)
{
fscanf(fp,”%s%d%f%d”,item,&number,&prince,&quality);
value=price*quantity”);
fprintf(“stdout,”%s%d%f%d%dn”,item,number,price,quantity,value);
}
fclose(fp);
}

Random access to files:

Sometimes it is required to access only a particular part of the and not the complete file. This can be accomplished by using the following function:

1 > fseek

fseek function:

The general format of fseek function is a s follows:

fseek(file pointer,offset, position); 

This function is used to move the file position to a desired location within the file. Fileptr
is a pointer to the file concerned. Offset is a number or variable of type long, and position in an integer number. Offset specifies the number of positions (bytes) to be moved from the location specified bt the position. The position can take the 3 values.

Value Meaning
0 Beginning of the file
1 Current position
2 End of the file.

Wednesday, May 4, 2011

Make Your Website.......India's Best Web Designing Company

The Web Dream 
               The Web Designing Company.........


Make your website and give information to global world. The Web Dream is a web designing company.......know more details on www.thewebdream.com ..........



Website : www.thewebdream.com
Email: info@thewebdream.com
Call: 09722210225

Make Your Website.......India's Best Web Designing Company

The Web Dream 
               The web designing Company.........


Make your website and give information to global world. The Web Dream is a web designing company.......know more details on www.thewebdream.com ..........

Website : www.thewebdream.com
Email: info@thewebdream.com
Call: 09722210225