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

  • Home
  • SEARCH
  • 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 6766489
In Process

The Archive Base Latest Questions

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

In one file I have this: #include <stdio.h> #include <stdlib.h> static struct node* mynode;

  • 0

In one file I have this:

#include <stdio.h>
#include <stdlib.h>

static struct node* mynode;

struct node*
example(void)
{
    mynode = malloc(sizeof(struct node));
    ...fill up the struct here...
    return mynode;
}

The calling routine is:

#include <stdio.h>
#include <stdlib.h>

int
main(void)
{
    mynode=example();
}

The node itself is defined in a defs.h file I don’t show here.
The warning I get when compiled with gcc is “assignment makes pointer from integer without a cast” in the calling routine.

Changing to mynode=(struct node*)example(); removes that warning. The routine works in any case but I don’t understand why I’m getting the warning.

  • 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:50:14+00:00Added an answer on May 26, 2026 at 2:50 pm

    In the file calling example, the return type of example is not known, so it is assumed to return an int, which you assign to struct node *. Hence the warning.

    You should either declare the prototype for example in the calling file (typing in struct node* example(void); before the calling function) or (better) create a header file called, say, example.h, where you type in the prototype and then include the header file in the calling file (that is, typing in #include "example.h" at the top). The header file thus defines the interface of the file whereexample` is located, and the files using the functions can include the header file, thus making sure all the types match, and removing any compiler warnings.

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

Sidebar

Related Questions

This is driving me crazy. I have this one php file on a test
I have one audio file captured from my iphone. I want to upload this
Let's say you have a text file like this one: http://www.gutenberg.org/files/17921/17921-8.txt Does anyone has
I have an xml file like this: <root> <item> <name>one</name> <status>good</status> </item> <item> <name>two</name>
I used to have one class for one file. For example car.cs has the
I have one file in my project, (the readme file,) which I would like
I have problem with session in cakephp.I have one file chat.php that is in
If I have the core of a class defined in one file as public
I have recently converted 10 JavaScript files into one file, which I then run
I have written a simple Hello World program. #include <stdio.h> int main() { printf(Hello

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.