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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:34:14+00:00 2026-06-02T16:34:14+00:00

Here is a small program I wrote, (I am still writing it), however till

  • 0

Here is a small program I wrote, (I am still writing it), however till this point the program on compilation should not be giving any error as per my understanding.

#include <stdio.h>
#include <stdlib.h>
struct node t1 {
        int data;
        struct node *next, *prev;
};
struct node *root;
root = NULL;
int main()
{
        int i, j, choice, count;
        printf("enter choice\n");
        scanf("%d", &choice);
        count = 0;
        while (choice == 1) {
                printf("enter a data element");
                scanf("%d", &j);
                count++;
        }

}

void push()
{
}

void pop()
{
}

The error I get is

 cc linklist.c
linklist.c:3:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
linklist.c:8:1: warning: data definition has no type or storage class [enabled by default]
linklist.c:8:1: error: conflicting types for ‘root’
linklist.c:7:14: note: previous declaration of ‘root’ was here
linklist.c:8:8: warning: initialization makes integer from pointer without a cast [enabled by default]

I use gcc and Ubuntu 11.04.
What is the reason that upon compiling the code I get above 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-06-02T16:34:15+00:00Added an answer on June 2, 2026 at 4:34 pm
    struct node *root;
    root = NULL;
    

    You can’t assign like that outside a function. Drop the root = NULL since it’s implicit for objects with static storage (such as global variables).

    EDIT

    As spotted by Tom Dignan the struct declaration is also wrong:

    struct node t1 { ... };
                ^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a small test program I wrote: #include <iostream> using namespace std; class A
I wrote this small program to find all occurrences of a substring in a
I wrote this small program today and I was blown away by the results.
Here is a small program showing a problem: import Data.Fixed main = do print
i have a small problem here which i cannot fix,This post goes through but
I wrote a small program that uses Mechanize to traverse a site. I want
I wrote a small program in VS2005 to test whether C++ global operator new
I'm trying to make a GUI for a small program I wrote with the
So I wrote a small program to try out Boost Filesystem. My program will
I am writing some small program in C--some log in, log out, create account,

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.