I am working with a function declaration of:
int func1(char *, unsigned int)

to the best of my understanding, I am not allowed to modify this. Now my question is that when I actually write this program what is the name of argument 1 and 2

for example

int intToHexStr(char *, unsigned int)
  //how do I reference the first argument?
  //and how do I reference the second argument?

Please help, thanks in advance!

9 Years
Discussion Span
Last Post by paradox814

What you've been given is the function prototype, which describes to the compiler the "signature" of the function. When you write your implementation (definition) of it, you must supply parameter names for the function to use. So in your program, it might look like:

#include <iostream>
using namespace std;

int func1(char *, unsigned int); //prototype, note the semicolon at end

int main( )
     char str[256] = "";
     int num = 3;
     int ret_val = 0;

     ret_val = func1( str, num );

     return 0;

int func1(char * foo, unsigned int bar) //parameter names here
      strcpy( foo, "hello" );
      for( int i = 0; i < bar; i++ )
          strcat( foo, " world" );
      return strlen( foo );
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.