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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:35:36+00:00 2026-06-05T09:35:36+00:00

Say I have a two functions like the ones below: unsigned char PlusTwo(unsigned char

  • 0

Say I have a two functions like the ones below:

unsigned char PlusTwo(unsigned char value)
{
    return (value + 2);
}
unsigned char PlusTwoUsingPtr(unsigned char *value)
{
    return (*value + 2);
}

If I want to test the first function while I’m developing, no problem, all I have to do is this:

PlusTwo(8);

The compiler will automatically place a constant somewhere in memory for me. However, to test the second function, it gets more complicated. First I have to declare a variable, then pass the function the address of the variable:

unsigned char eight = 8;
PlusTwoUsingPtr(&eight);

This isn’t horribly time consuming, but it is annoying (particularly in C89/ANSI where variables have to be declared at the beginning of a function block). Is there some trick that will allow me to just test this function in one line of code, having the compiler declare & place a constant somewhere for me to point to?

  • 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-05T09:35:38+00:00Added an answer on June 5, 2026 at 9:35 am

    You can use a compound literal with a scalar type:

     PlusTwoUsingPtr(&((unsigned char){8}));
    

    Compound literal is a feature introduced in C99.
    For information the object is mutable (with static storage duration) and you can also modify it in your function.

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

Sidebar

Related Questions

I have two functions here say animation1 and load1 they work like that: function
I would like to have two functions: Say I have the date in a
Lets say I have two functions: def foo(): return 'foo' def bar(): yield 'bar'
Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);
Lets say i have two inline functions in my header file: inline int foo()
Let's say for example that I have two functions with random code inside and
So let's say I have two different functions. One is a part of the
I'll try to explain with an example... Let's say I have two different functions,
Lets say I have a function f[x_, y_] , and two lists l1 ,
Say we have two tables in an MS Access db: Service Users: | ID

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.