Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

function arguments

Posted on 1998-07-28
4
363 Views
Last Modified: 2010-04-15
Hi
Is there a way I could reffer the arguments of a function the same way as the arguments for the main function ?
ex.

void dummyFunction(char* arg1, char* arg2, char* arg3)
{
int count;
    for(count = 0; count < 3; count++)
    {
            alocate memory for each argument one by one
    }
}

Thanks
0
Comment
Question by:simi
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1251839
/* I'm not sure what alocate memory for each argument one by one is supposed to do, but perhaps you mean something like this? */
void dummyFunction( char *args[3] ){
  int count;
   for( count = 0; count < 3; count++ ){
       char *copy;
       copy = malloc(strlen(args[count])+1);
       strcpy(copy,args[count]);
       printf("%s\n",copy);
       free(copy);
   }
}
main(){
   char *args[3] ={"hello", "world", ""};
   dummyFunction(args);
}

0
 

Author Comment

by:simi
ID: 1251840
Thanks
0
 

Author Comment

by:simi
ID: 1251841
I want to grade your answer but the system just provide me with the posibility to write a comment. The grading part has vanished.
How can I grade it ?
0
 
LVL 84

Accepted Solution

by:
ozo earned 20 total points
ID: 1251842
You can't grade it because I didn't submit an answer, because I wasn't sure what the question was.
But since it sounds like you have nevertheless gotten what you needed, I'll submit one now.
If there was anything you wanted clarified, please comment.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question