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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:03:14+00:00 2026-05-14T03:03:14+00:00

The following code outputs Illegal seek: #include <stdio.h> #include <errno.h> #include <string.h> int main()

  • 0

The following code outputs “Illegal seek”:

#include <stdio.h>
#include <errno.h>
#include <string.h>

int main() {
    errno = 0;
    getchar();
    getchar();
    getchar();
    ftell( stdin );
    printf( "%s\n", strerror(errno) );
}

This occurs when I run cat script | ./a.out as well as when I just run ./a.out. The problem is with ftell, of course. My question is: why does this occur? I would think stdin can be seekable. fseek also causes the same error. If stdin is not seekable, is there some way I can do the same sort of thing?

Thank you for your replies.

  • 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-14T03:03:14+00:00Added an answer on May 14, 2026 at 3:03 am

    Fifos aren’t seekable. They are simply a buffer. Once data has been read() from a fifo buffer, it can never be retrieved.

    Note that if you ran your program:

    ./a.out < script
    

    then standard input would be a file and not a fifo, so ftell() will then do what you expect.

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

Sidebar

Related Questions

The following code outputs a random number each second: int main () { srand(time(NULL));
I was surprised to find that the following code System.out.println("Character size:"+Character.SIZE/8); System.out.println("String size:"+"a".getBytes().length); outputs
Rather than outputting the expected string of Bar , the following code outputs what
I have the following code: <%= Html.Encode(String.Format({0:g}, item.startDate)) %> It outputs something like 01/01/2011
Consider the following code: #include<iostream> using namespace std; class sample { int a; int
The following code outputs an empty string. The cause is the ó in $text,
The following code outputs 1970-01-01 which is wrong. <?php $dob='17 Jan 1900'; $datetime =
I build a CodeCompileUnit and the following code outputs a C# source code file,
I have the following code which outputs an object to an XML file: using
The following code seemed really confusing to me since it provided two different outputs.The

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.