From: joy <gracecott@sancharnet.in>
To: linux-c-programming@vger.kernel.org
Subject: problem in open sys call
Date: Wed, 21 Apr 2004 00:01:40 +0530 [thread overview]
Message-ID: <40856C8C.9090003@sancharnet.in> (raw)
[-- Attachment #1: Type: text/plain, Size: 112 bytes --]
Hi,
I have a small prblem i the open call. it fails every time and I dont
know why.
thanx in advance,
Joy.M.M
[-- Attachment #2: opgen.c --]
[-- Type: text/plain, Size: 1021 bytes --]
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
const char opcode[]="opcode.sheet";
const char target[]="opcode.sheet";
main()
{
char buff[8192],temp[10],bin=0,opcode[3];
int fd,fd1,bytes_read=8192,count,i=0,inter_count=0;
int offset=0,j=0,tempy;
char head[]="OPCODE SHEET";
if((fd=open(opcode, O_RDONLY))==-1)
printf("oops");
if((fd1=open(target, O_RDWR|O_CREAT))==-1)
printf("O");
while(bytes_read==8192)
{
bytes_read=read(fd,buff,8192);
while(inter_count<bytes_read)
{
i=0;
do
{
bin=buff[inter_count];
temp[i]=buff[inter_count];
inter_count++;
i++;
}while(bin!=10);
temp[i++]=0;
j=0;
write(fd1,head,sizeof(head));
for(j=0;j<i;j++)
{
tempy=(int)(temp[j]-0);
offset+=tempy;
}
if(lseek(fd1,offset,SEEK_SET)==-1)
printf("HI");
printf("%s : ",temp);
scanf("%s",opcode);
write(fd1,opcode,sizeof(opcode));
printf("%s %d \n",temp ,offset);
}
}
return(0);
}
next reply other threads:[~2004-04-20 18:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-20 18:31 joy [this message]
2004-04-20 20:06 ` problem in open sys call Glynn Clements
2004-04-21 9:00 ` joy
2004-04-20 21:35 ` Steven Smith
2004-04-21 6:14 ` Vadiraj C S
-- strict thread matches above, loose matches on Subject: below --
2004-04-20 19:22 Huber, George K RDECOM CERDEC STCD SRI
2004-04-21 9:10 ` joy
2004-04-21 10:08 ` Holger Kiehl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40856C8C.9090003@sancharnet.in \
--to=gracecott@sancharnet.in \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).