| | |
Help with function declaration
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
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
C++ Syntax (Toggle Plain Text)
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:
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 ); }
Everyone's gotta believe in something. I believe I'll have another drink.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
![]() |
Similar Threads
- Passing 2D Array of Pointers into a function (C++)
- 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++)
- 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
Views: 1867 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






