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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:10:13+00:00 2026-05-26T01:10:13+00:00

I need to declare an array that consists of different variable types, mainly: char

  • 0

I need to declare an array that consists of different variable types, mainly:

char *A; uint32_t B; int C;

As I understood in the tutorials, in the array you declare the type and the number of element. So to say something like:

int a[3];

where in this case, the type of the three elements are all integers.
So how do I want to declare an array that consists of the three different types mentioned above?

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

    The definition of an array in C is a collection of elements of the SAME type. What you are looking for is probably a struct.

    struct s
    {
        char* A;
        uint32_t B;
        int C;
    };
    
    int main(void)
    {
        struct s test;
        test.A = "Hello";
        test.B = 12345;
        test.C = -2;
    
        // Do stuff with 'test'
        return 0;
    }
    

    Or, as mentioned in a comment below, you could use a union instead. But then you can’t use A, B, and C at the same time like I have in the example above – only one of them will be stored – in my example it would be C.

    You can make an array of structures if you need to.

    struct s test[5];  // Array of structures
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to declare 3d array variable but can't. int[][][] ary = new int[5][2][];
I need to declare the query variable outside the switch statement that way I
I need to declare a boost::array. I did it as boost::array<char, 116> buf; is
I need to declare an array of pointers to functions like so: extern void
I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
I have a vector declared as a global variable that I need to be
I have a small question. Do i need to declare an array if i
I need to declare a global two-dimensional array in C. The size of the
I need to declare a function in F# that takes 2 parameters (row, col)
I have an array which stores a dictionary of Types: //The dictionary: Dictionary<CacheKey,Type> TypeLookup;

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.