—————————-
revision 1.1
date: 2014/03/19 21:16:30; author: emblogic; state: Exp;
Initial revision
—————————-
revision 1.1
date: 2014/03/19 21:16:30; author: emblogic; state: Exp;
Initial revision
—————————-
revision 1.1
date: 2014/03/19 21:16:30; author: emblogic; state: Exp;
Initial revision
—————————-
revision 1.1
date: 2014/03/19 21:16:30; author: emblogic; state: Exp;
Initial revision
head 1.1;
access;
symbols;
locks; strict;
comment @ * @;
1.1
date 2014.03.20.02.00.48; author root; state Exp;
branches;
next ;
desc
@this is the program to copy contents of one file into another using fputc.
@
1.1
log
@Initial revision
@
text
@#include
#include
int main()
{
FILE *fp, *fp1;
char ch,ch1;
fp=fopen(“/home/priya/pp1.c”,”r”);
fp1=fopen(“/home/priya/palak1.c”,”w”);
do
{
ch=fgetc(fp);
ch1=fputc(ch,fp1);
}
while(ch !=10);
// printf(” the string is ch is %c”,ch);
// printf(“the string is ch is %c”,ch1);
return 0;
}
@
@This is a program to copy the contents of one file into another using fputc.
@
1.1
log
@Initial revision
@
text
@#include<stdio.h>
int main()
{
FILE *fp1,*fp2;
char a;
fp1=fopen(“file2″,”r”);
if(fp1==NULL)
{
puts(“cannot open this file”);
goto OUT;
}
fp2=fopen(“file1″,”w”);
if(fp1==NULL)
{
puts(“cannot open this file”);
goto OUT;
}
do
{
a=fgetc(fp1);
fputc(a,fp2);
}
while(a!=EOF);
return 0;
OUT:
return -1;
}
@
head 1.1;
access;
symbols;
locks; strict;
comment @ * @;
1.1
date 2014.03.19.07.00.53; author Emblinux; state Exp;
branches;
next ;
desc
@this is a program to find out even and odd numbers.
@
1.1
log
@Initial revision
@
text
@#include<stdio.h>
int main()
{
int a[5],i,k;
printf(“enter all five numbers”);
for(i=0;i<5;i++)
scanf(“%d”,&a[i]);
for(k=0;k<5;k++)
{
if(a[k]%2==0)
printf(“this is even number : %d”,a[k]);
else
printf(“this is odd number : %d”,a[k]);
}
return 0;
}
@
>> this is the program using pointers
>> in which we count the positive no.s in array and exit when zero is found
>> there must b atleast one zero in the array
>> .
initial revision: 1.1
done
[root@localhost puja]# rlog vim 7p8.c,v
rlog: RCS/vim,v: No such file or directory
RCS file: 7p8.c,v
Working file: 7p8.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
this is the program using pointers
in which we count the positive no.s in array and exit when zero is found
there must b atleast one zero in the array
—————————-
revision 1.1
date: 2014/03/08 10:29:51; author: emblogic; state: Exp;
Initial revision
>> this is a program to print the first byte of each element from an integer array
>> using pointers
>> .
initial revision: 1.1
done
[root@localhost puja]# rlog vim 7p7.c,v
rlog: RCS/vim,v: No such file or directory
RCS file: 7p7.c,v
Working file: 7p7.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
this is a program to print the first byte of each element from an integer array
using pointers
—————————-
revision 1.1
date: 2014/03/08 10:39:55; author: emblogic; state: Exp;
Initial revision
RCS file: 7p9.c,v
Working file: 7p9.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
this is a program to enter the phone number and separate the area code and phone no.
using pointers
—————————-
revision 1.1
date: 2014/03/08 11:39:19; author: emblogic; state: Exp;
Initial revision
>> this is the program for addition of two distance in feet and inch
>> using function
>> .
initial revision: 1.1
done
[root@localhost puja]# rcs 9p1.c,v
rcs: warning: No options were given; this usage is obsolescent.
RCS file: 9p1.c,v
done
head 1.2;
access;
symbols;
locks
root:1.2; strict;
comment @ * @;
1.2
date 2014.03.15.16.06.03; author root; state Exp;
branches;
next 1.1;
1.1
date 2014.03.14.06.52.50; author root; state Exp;
branches;
next ;
desc
@this is the initial version,file created and open using function().
@
1.2
log
@implemented masterarray using function
@
text
@#include”header.h”
int main(int argc, char *argv[])
{
int fd,ret;
if(argc !=2)
{
printf(“insufficient arguments !!”);
goto out;
}
fd=openfile(argv[1]);
masterarray(fd);
return 0;
out:
return -1;
}
int openfile(char *ipfile)
{
int fd;
fd = open(ipfile,O_RDONLY);
if(fd<0)
{
perror("open");
goto out;
}
printf("file discriptor : %d",fd);
return fd;
out:
return 0;
}
int masterarray(int fd)
{
int ret,i,ndc=0;
char ch;
char masterarray[128];
do
{
ret=read(fd,&ch,1);
if(ret<0)
{
perror("read");
close(fd);
goto out;
}
if(ch!=10)
{
masterarray[ndc]=ch;
ndc++;
}
}while(ch!=10);
for(i=0;i<ndc;i++)
printf("read %d char ch=%c \n",ret,masterarray[i]);
out:
return -1;
return 0;
}
@
#include
#define size 10
int main()
{
int arr[size];
int i,j,temp;
printf(“Enter the array \n”);
for(i=0;i<size;i++)
scanf("%d",&arr[i]);
printf("The array is :\n");
for(i=0; i < size; i++)
printf("arr[%d]:%d\n",i,arr[i]);
printf("String after bubble sort ");
for(j=0 ; j<size ; j++)
{
for(i=0 ; i arr[i+1])
{
temp=arr[i+1];
arr[i+1]=arr[i];
arr[i]=temp;
}
}
for(i=0 ; i<size ; i++)
printf("arr[%d] :%d\n ",i,arr[i]);
return 0;
}
head 1.1;
access;
symbols;
locks
root:1.1; strict;
comment @ * @;
1.1
date 2014.03.14.06.52.50; author root; state Exp;
branches;
next ;
desc
@this is the initial version,file created and open using function().
@
1.1
log
@Initial revision
@
text
@#include”header.h”
int main(int argc, int *argv[])
{
int fd,ret;
char ch;
if(argc !=2)
{
printf(“insufficient arguments”);
goto out;
}
fd=openfile(argv[1]);
do
{
ret=read(fd,&ch,1);
if(ret<0)
{
perror("read");
close(fd);
goto out;
}
if(ch!=10)
{
masterarray[ndc]=ch;
ndc++;
}
}while(ch!=10);
for(i=0;i<ndc;i++)
printf("read %d char ch=%c \n",ret,masterarray[i]);
return 0;
out:
return -1;
}
int openfile(char *ipfile)
{
int fd;
fd = open(ipfile,O_RDONLY);
if(fd<0)
{
perror("open");
goto out;
}
printf("file discriptor : %d",fd);
return fd;
out:
return 0;
}
@
created FIFO between two process. In this one process is writing and another process is reading using named pipes that is FIFO.
elements using pointer.
>> .
initial revision: 1.1
done
[root@localhost priya]# rlog avgptr.c,v
RCS file: avgptr.c,v
Working file: avgptr.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
this is a program in which we have calculated the average of array elemsing pointer.
—————————-
revision 1.1
date: 2014/03/06 11:14:55; author: root; state: Exp;
Initial revision