•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 427,199 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,278 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 430 | Replies: 2 | Solved
![]() |
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation:
Rep Power: 4
Solved Threads: 2
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
Please help, thanks in advance!
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!
•
•
Join Date: Aug 2007
Location: South Dakota
Posts: 861
Reputation:
Rep Power: 6
Solved Threads: 86
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:
c++ Syntax (Toggle Plain Text)
#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 ); }
I think congressmen should wear uniforms like NASCAR drivers so we could identify their corporate sponsors. (unknown)
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Function Back to Main (C++)
- Passing a Value between an Array and Another Function (C++)
- Passing a matrix from main function to user defined function. (C++)
- Passing 2D Array of Pointers into a function (C++)
- C++ Passing Function to Function (C++)
- function declaration in MatLab (Legacy and Other Languages)
- declaration syntax error? (C++)
Other Threads in the C++ Forum
- Previous Thread: How to link an MFC form to source code?
- Next Thread: More on my first uni assignment


Linear Mode