How would you get the character positions 10-20 from a text file

Showing Answers 1 - 2 of 2 Answers

anup

  • Oct 25th, 2006
 

You can use 'cut' command

cut -c10-20 <file_name>

  Was this answer useful?  Yes

mekala

  • Jan 5th, 2007
 

    #include<stdio.h>
int main()
{
char ch;
int i,count=0;
FILE *fp=fopen("check.txt(txt file)","r");
while(!feof(fp))
 {
        for(i=1;i<35;i++)
        {
            ch=getc(fp);
            if(ch=='n')
                {
                printf("n");
                }
            else
                {count++;
                if((count>10)&&(count<20))
                printf("%cn",ch);
                }
         }
 }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions