Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7841667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:08:53+00:00 2026-06-02T16:08:53+00:00

I am trying to write a C program to get the character in the

  • 0

I am trying to write a C program to get the character in the file which is ofset by some bytes, lets say three as below

fseek(fp,3,SEEK_CUR);

I wish to print the character which that particular byte represents. For example if my file contains something like below,I need to print every third character.

//reading from file//

The problem is that after using a while loop I am not able to print the desired result. The first character which gets printed is the fourth character instead of third.

while(fp!=EOF)
{
    fseek(fp,3,SEEK_CUR);
    ch = fgetc (fp);
    printf("%c",ch);
}

Can you please help me in understanding what is the mistake with this. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:08:55+00:00Added an answer on June 2, 2026 at 4:08 pm

    fgetc moves the file offset by one. Try the following:

    fseek(fp,3,SEEK_CUR);
    while(fp!=EOF)
    {
        ch = fgetc (fp); // moves offset by 1
        fseek(fp,2,SEEK_CUR); // moves offset by another 2
        printf("%c",ch);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to write a program which get two 6-digit decimal numbers and show
I'm trying to write a program that takes a large file (of any type)
I am trying to write a program wit Perl which should returns the frequency
I am trying to write a program which will listen to the serial input
I'm trying to write a program that will write some data to a temporary
I'm trying to write a program using SQL and OleDB and I get an
I'm trying to write a C++ program that alters a .txt file. However when
I'm new to c and I'm trying to write a c program that get
I am trying to write a program that allows a binary to be run,
I'm trying to write a program in Python and I'm told to run an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.