#include<stdio.h>
void main(int argc , char *argv[])
{
FILE *file;
char *string[100];
int count = 0,n=0;
// initialise file pointer to read
file = fopen(argv[3],"r");
// string to int
n = atoi(argv[2]);
// read character by character
while(file , "%c" , string)!=EOF)
{
// break after n characters
if(count == n)
{
break;
}
else
{
printf("%c" , line);
}
count++;
}
fclose(file);
}
output:
cc head.c
./a.out -c bytes filename
void main(int argc , char *argv[])
{
FILE *file;
char *string[100];
int count = 0,n=0;
// initialise file pointer to read
file = fopen(argv[3],"r");
// string to int
n = atoi(argv[2]);
// read character by character
while(file , "%c" , string)!=EOF)
{
// break after n characters
if(count == n)
{
break;
}
else
{
printf("%c" , line);
}
count++;
}
fclose(file);
}
output:
cc head.c
./a.out -c bytes filename
Comments
Post a Comment