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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:43:11+00:00 2026-05-13T12:43:11+00:00

FILE *fd; if (fd=fopen(fileName,r) == NULL) { printf(File failed to open); exit(1); } This

  • 0
FILE *fd;
if (fd=fopen(fileName,"r") == NULL)
{   
    printf("File failed to open");
    exit(1);
}

This is a code snippet. When I compile it with gcc, i get the following warning:-

warning: assignment makes pointer from integer without a cast

When I put fd=fopen(argv[2],”r”) within brackets, the problem gets solved..

I am not able to understand where am i converting integer to pointer when the brackets are not put.

  • 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-13T12:43:11+00:00Added an answer on May 13, 2026 at 12:43 pm

    Due to operator precedence rules the condition is interpreted as fd=(fopen(fileName,"r") == NULL). The result of == is integer, fd is a pointer, thus the error message.

    Consider the “extended” version of your code:

    FILE *fd;
    int ok;
    fd = fopen(fileName, "r");
    ok = fd == NULL;
    // ...
    

    Would you expect the last line to be interpreted as (ok = fd) == NULL, or ok = (fd == NULL)?

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

Sidebar

Related Questions

I tried to create a file using Oracle UTL_FILE.FOPEN command but i get this
I'm learning about pointers. Given this code: FILE* from = fopen("in.txt", "r"); FILE* to
I tried to open a file with fopen() function in PHP and it output
I am writing a PHP code that creates another PHP file with fopen and
What is wrong with strcpy() in this code? void process_filedata(char *filename) { void* content;
While reading a binary file using DJGPP on DOS this code hangs. This happens
I'm using this code inside a function to get the shortest and longest string
Possible Duplicate: PHP create a file without fopen I want to create a file
I am having trouble figuring out how to write to a file using fopen
Using PHP, it's possible to read off the contents of a file using fopen

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.