| | |
Help with function declaration
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
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: 1871 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






