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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:00:48+00:00 2026-05-26T19:00:48+00:00

Imagine if for any reason, you want to create several variables, and without using

  • 0

Imagine if for any reason, you want to create several variables, and without using an array, and they must have different names. Logically, you will not create empty variables and set 500 only as needed.

In short, it is possible to generate a variable with the same name without the random use of an array or vector?

If possible, I would like the instantiation logic or C or C++.

I’ve tried in this method (In C), but doesn’t work:

#include <stdlib.h> // for random

#define RANDOM random(100)

int main ( void )
{
    int n/**/RANDOM = 5;
    return 0;
}

Possibly older compilers work, because they remove the comment. Current compilers consider the comment as a space.

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

    At least on recent GCC, you can use tricks like

     #define NEWVAR_NUM(Var,Num) { static int Var_##Num; foo(&Var_##Num); }
     #define NEWVAR(Var) NEWVAR_NUM(Var,__COUNTER__)
    

    On other (or with standard conforming) compilers, you can use __LINE__ instead of __COUNTER__. See Common Predefined Macros of GCC and cpp’s concatenation

    Also, you could consider generating such contrived C code, with e.g. m4 or your own generator (which can be a ten line script or a 100K line generator).

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

Sidebar

Related Questions

Is there any way to check if a particular plugin is available? Imagine that
Good morning all. Is there any jsf control that escapes the html tags? Imagine
Imagine we have a program trying to write to a particular file, but failing.
Imagine you want to animate some object on a WinForm. You setup a timer
Imagine I have an function which goes through one million/billion strings and checks smth
Imagine a GPS tracking system that is following the position of several objects. The
Possible Duplicate: Do write-only properties have practical applications? A getter without a setter makes
I would like to test if a URL exists without loading any actual data.
I have started using Linq to SQL in a (bit DDD like) system which
At work today we were trying to come up with any reason you would

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.