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 6766289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:48:43+00:00 2026-05-26T14:48:43+00:00

Is there a way to find the character stored in file pointer without fgetc.

  • 0

Is there a way to find the character stored in file pointer without fgetc.
Say I have a word “steve jobs” in a file called apple.txt is there something like

int main(int argc,char *argv[])
  {
   FILE *fp=fopen("apple.txt","r");
   if(fp=='s'&&(fp+2)=='e')
     printf("steve is there");
   else
     printf("Steve not there");
   fclose(fp);
  }

Clearly this doesn’t really work! It just prints something like C forbids comparison b/n pointer n int. Even i tried adding * in front of (fp+2) and fp, it said no match for operator==

I believe the function fgetc(FILE *) works in such a way that it gets the unsigned char and then moves the pointer to the next location. Is there any function to just get the character without moving the pointer and also is the above code possible in any other way?!

  • 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-05-26T14:48:44+00:00Added an answer on May 26, 2026 at 2:48 pm

    You might use getc and ungetc. Read the documentation about it (you can only have one push-back character).

    On some systems (notably Posix systems like Linux) you have the ability to map into memory a portion of a file. Read more about the mmap system call which enables you to see a portion of a file as segment of memory. (mmap is not usable on non-seekable files like pipes or sockets; it basically works mostly on “disk” files).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a relatively easy way to find an instance of a character, say
Is there any way to find out if a file is a directory? I
Is there a way to find the size of a file object that is
Is there any way to find which input character fails the regex pattern .
In Java is there a way to find out if first character of a
Is there any way I can find a Unicode character's bidirectional character type in
Is there a way to find the name of the program that is running
Is there a way to find the number of files of a specific type
Is there a way to find the maximum and minimum defined values of an
Is there a way to find the number of lines of code used in

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.