Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Showing posts with label C-File. Show all posts
Showing posts with label C-File. Show all posts

Friday, May 20, 2011

C36 : Read values from command line and print it

Back to Home   &  C


//Program to read values from command line and print it

#include<stdio.h>
#include<conio.h>
void main(int argc,char *argv[])
{
for(i=1;i<argc;i++)
{
printf("%s\n",arv[i]);
}
}
--------------------------------------------------------------
Output:


=========================================================================
Back to Home   &  C

C35 : Write and read employee details from a file

Back to Home   &  C


//Program to write and read employee details from a file

#include<stdio.h>
#include<conio.h>
void main()
{
int code;
char name[20];
FILE*fp;
fp=fopen("emp.dat","w+");
clrscr();
printf("Enter employee code");
scanf("%d",&code);
printf("Enter name");
scanf("%s",name);
printf("Writing to file...\n");
fprintfp("%d%s",code,name);
printf("Reading from file...\n");
fprint(fp,"%d%s",&code,name);
printf("Employee code=%d\n",code);
printf("Name=%s\n",name);
getch();
}
---------------------------------------------------------------------
Output :

=========================================================================
Back to Home   &  C