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!

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 );
}

Thanks! I guess I should have been able to figure that out!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.