How do i include cat -n command in my program implementation This is the problem with my program and i cant get it to print a new line number after every line so any suggestions on what i could do to rectify this
if(argv[1] == "-n")
{
fd = open(argv[i],O_RDONLY);
printf("%d\t",line);
while(n = read(fd,&s,1) > 0)
{
if(s == '00')
{
line++;
printf("\n%d\t",line);
}
printf("%c",s);
}
}
while (n = read(fd,&s,1) > 0)
missing parentheses. >
has higher precedence than =
.
if(s == '00')
This is not how you detect an end of line. An end of line is typically a '\\n'
character in unix-like systems.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.