Hiii....
I am stuck here..
I want a function which can return a string and also it should be able to take DEFAULT string arguments....
can anyone help me wid d syntax??
akand
0
Newbie Poster
Recommended Answers
Jump to Poststring foo(string myStr);
Was that so difficult?
Jump to PostI'd personally overload the functions, rather than specifying default arguments.
EDIT:
so for the above one...
char* fun(char* a="awe", char* b="ahgsh");Yes.
Jump to Postchar *foo(char *a="a",char *b="b", char *c="c") { cout<<a<<b<<c; return c; } int main(int argc, char *argv[]) { foo(); return 0; }
As I said earlier this is fine, but I'd rather overload the foo function to accept multiple/no arguments.
Jump to Postnbaztec, this is the C forum. C++ does not work here. ;)
> I want a function which can return a string and also it should be able to take DEFAULT string arguments....
C does not support either default arguments or function overloading, so the simple answer is you …
Jump to PostWell I know that C supports none. But I wanted to help the OP rather than shoo him off to C++ forum. :)
This thread can(should) be moved right?
All 20 Replies
nbaztec
45
Posting Pro in Training
akand
0
Newbie Poster
akand
0
Newbie Poster
nbaztec
45
Posting Pro in Training
nbaztec
45
Posting Pro in Training
akand
0
Newbie Poster
nbaztec
45
Posting Pro in Training
akand
0
Newbie Poster
nbaztec
45
Posting Pro in Training
akand
0
Newbie Poster
Radical Edward
301
Posting Pro
nbaztec
45
Posting Pro in Training
Radical Edward
301
Posting Pro
akand
0
Newbie Poster
nbaztec
45
Posting Pro in Training
Radical Edward
301
Posting Pro
akand
0
Newbie Poster
nbaztec
45
Posting Pro in Training
Radical Edward
301
Posting Pro
nbaztec
45
Posting Pro in Training
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.