I have a small program that I am trying to write. The point of the program is to accept 3 parameters: -h | -b buf | source | target
The -h if active, creates a file with holes
The -b nbuf is supposed to allow the user to enter a specified amount for the buffer when reading and writing to a file.
The source is the source file and the target is a target file. The code that I have so far is as follows. One problem that I am having is that I receive the following errors upon compilation:
my.c: In function `main':
my.c:15: warning: assignment makes integer from pointer without a cast
my.c:19: warning: passing arg 1 of `read' makes integer from pointer without a cast
my.c:19: warning: passing arg 2 of `read' makes pointer from integer without a cast
my.c:32: warning: passing arg 1 of `write' makes integer from pointer without a cast
my.c:32: warning: passing arg 2 of `write' makes pointer from integer without a cast
my.c:33: warning: passing arg 1 of `lseek' makes integer from pointer without a cast
Below is the code that I have written
Quote:
int main ( int argc, char *argv[] )
{
int wfile;
// Set the buffer to argc2
int buffer;
buffer = argv[2];
int count;
// Read the information in file argv3
count = read(argv[3],buffer,1);
if (argv[1] != "-h")
{
// Create the target file. Output error if file cannot be created
if ((wfile = creat(argv[4], S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0)
{ printf("Unable to create target file, check permissions\n");
}
// Read and write all of the contents from source file to the new file
while (count != EOF)
{
// Write the file content
write(argv[4],buffer,1);
lseek(argv[3],count++,SEEK_SET);
}
}
else
{
// Create file with holes
}
exit(0);
}
|