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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:00:36+00:00 2026-05-20T01:00:36+00:00

I am unsure how to declare a global union in C. Below is my

  • 0

I am unsure how to declare a global union in C. Below is my code (all of which is outside of main).

typedef union{
    int iVal;
    char* cVal;
} DictVal;
struct DictEntry{
    struct DictEntry* next;
    char* key;
    DictVal val;

    int cTag;
};

DictVal find(char* key);

int main()
{
    struct DictEntry dictionary[101];
    //printf("Hello");
}

DictValue find(char* key)
{
  DictVal a;
  a.iVal = 3;
  return a;
}

With this, I receive the error:

test.c:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘find’.

How can I declare the union in a way that I can use it as a return type for a function?

Thank you in advance!
Andrew

  • 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-20T01:00:37+00:00Added an answer on May 20, 2026 at 1:00 am

    You’ve typo’ed.

    There’s a DictVal typedef but you tried to use DictValue on the definition.

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

Sidebar

Related Questions

I am unsure which way to declare my arrays with fixed size of 10
The following code does not work, and I am unsure why. DECLARE @TableName varchar(100)
I am unsure on which approach will give me a better performance: I have
I'm unsure what is going on or what I changed, but all of a
I am unsure why this code will not work. When I click a button
I have the following SQL query: Declare @Total_SysDown as int, @Login_SysDown as int Set
Unsure how to get this string to work correctly. Keeps making my page blank.
Unsure about static variables. import java.io.File; public class Logger { public static final File
I am unsure what would be the best way to implement a success message
I am unsure how to use the Distributive property on the following function: F

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.