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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:17:13+00:00 2026-06-18T00:17:13+00:00

I have many functions like: void write(char* param, int len) { // } And

  • 0

I have many functions like:

void write(char* param, int len)
{
    //
}

And I notice that I almost never use the & operator for arguments. When I pass an array:

char in[20];
write(in, 20);

I dont need it, but when I pass a single value:

write(5, 1);

I don’t seem to need it, and when I pass a pointer:

char* in = malloc(20);
write(in, 20);

I also dont need it. So in which circumstances do I actually need to call:

write(&in, 1);

Because I’m confused 😀

  • 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-18T00:17:14+00:00Added an answer on June 18, 2026 at 12:17 am

    When are values implicitly converted to pointers?

    In practice, integer types may be converted to pointers implicitly by the compiler. In theory, this is illegal and compilers that accept it will usually issue a warning:

    example.c:2:6: warning: incompatible integer to pointer conversion initializing
                   'void *' with an expression of type 'int'
    

    In your above example:

    char in = 5;
    write(in, 20);
    

    char is an integer type, so if your compiler allows it, it may be implicitly converted to a pointer type, although it is not part of the C standard and is completely compiler-specific.

    Note that converting an integer type to a pointer type using a cast is allowed by the standard, although results are implementation-defined:

    char in = 5;
    write((char *)in, 20);
    

    The only allowed case of implicit conversion is when integer constant 0, which denotes a null pointer:

    write(0, 20);    // allowed
    

    Note that the integer constant is itself allowed, but a variable of integer type with the value 0 is not:

    char in = 0;
    write(in, 20);   // not allowed
    

    As for the others, when you pass a pointer, you don’t need the &, obviously, because it’s already a pointer. When you pass an array, it decays to a pointer so you don’t need & there either. In both these cases it would be actually illegal to use it, as your function above expects a char * and be fed with a char ** and a char (*)[20] respectively.

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

Sidebar

Related Questions

I have many structs (classes) and standalone functions that I like to compile separately
I have many js methods that uses global variables like: function DoSomething() { var
Many people have argued about function size. They say that functions in general should
So I have a function that requires two characters and two ints: void need_2xcha_2xint(char
I would like to call JavaScript function many time . I have tried like
I have a js variable with many functions, and I want to create in
I have a c++ program which has many many functions and I have different
I have used many of the Convert.To..... functions for conversion , but I didn't
I have a function that counts how many times a words appears on a
I have a function that needs to call a virtual method many times in

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.