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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:05:39+00:00 2026-06-14T17:05:39+00:00

I am trying to write simple pgm file reading C program. I had to

  • 0

I am trying to write simple pgm file reading C program. I had to create simple structure:

typedef struct pgmImage {
   int R; //rows
   int C; //collumns
   int G; //grey scale
   int **pix;  // array of pixels
}Image;

Now i have to initialize empty Image structure.I need one to set all variables based on *.pgm file in other function.
All the time i am getting “unable to read memory” and ‘unitialized local variable x used’. I have tried to simply do :

Image *x=0;

but program crashes when read function try to set R,C,G values.

  • 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-14T17:05:40+00:00Added an answer on June 14, 2026 at 5:05 pm

    If you want a pointer to Image you have to initialize like this.

    Image *x = NULL;
    

    Accessing the image (x) camps like this :

    x-> C = 0;
    x-> ...
    x->pix = NULL;
    

    But first you need to allocate memory to your image.

    x = (Image*) malloc(sizeof(Image));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write header file. I can write simple headers like add(int
I am trying to write some simple code which will read a text file
I am trying to write simple program using ONLY for loop ( if then
I'm trying to write a simple program to calculate betweeness using brandes_betweenness_centrality from boostlib.
I am trying to write some simple program to uploading files to my server.
Trying to write a simple program that prints the Fibonacci sequence. I want to
Trying to write a simple C# script to copy file to directory one level
Trying to write simple program on Fraction operations. Can't compile the code. Getting an
I'm trying to write simple DAO that will create entity objects based on their
I am trying to write a simple test method to copy a file from

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.