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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:40:09+00:00 2026-05-12T09:40:09+00:00

I have opened a .txt file many times using the C language’s file handling

  • 0

I have opened a .txt file many times using the C language’s file handling facilities. But when I try to open an image file using the same procedure as for text files, I just can’t do that.
I even tried this by opening the image file in binary mode "rb".

This is the code I’m using:

#include "file.h"
#include "stdio.h"

main()
{
    FILE *fp;
    char ch;
    fp = fopen("D:\\setups\\tcc\\Bluehills.bmp", "rb+");

    if(fp == NULL)
    {
        printf("Error in opening the image");
        fclose(fp);
        exit(0);
    }

    printf("Successfully opened the image file");

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

    printf("\nWriting to o/p completed");
}

What do I need to modify to get the image as it is? As I’m directing the image output to the DOS window at least a monochrome pixel image must come up.

  • 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-12T09:40:10+00:00Added an answer on May 12, 2026 at 9:40 am

    As others have mentioned, since images are binary files you have to know how to “interpret” the data in them after reading them. Luckily, for most formats you can find libraries that do it for you like libpng or libjpeg.

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

Sidebar

Related Questions

I have opened one file with following way: fp = fopen(some.txt,r); Now in this
On a typical OS how many files can i have opened at once using
Using the following explorer.exe /select, c:\path\to\file.txt I can open Windows Explorer and select the
My file(sample.txt) has 10 chars. I opened the file in write mode, have done
Suppose I have a file opened with the C syntax FILE* fp = fopen(whatever.txt,
Do files opened like file(foo.txt) have any info about file modification time? Basically I
I have a switch configuration with me in config.txt file .I have opened this
i have tried this: <?php $fileip = fopen(test.txt,r); ?> this should have opened the
I have opened a JSP web project in Eclipse but not sure how to
I have opened www.makemytrip.com website and try to click on Round Trip radio button

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.